/* Family Recipe Book — shared shell.

   One stylesheet for all five pages. Light by default — the app is a paper
   recipe card on a kitchen counter — with a token-level dark palette under
   `prefers-color-scheme: dark`. Every colour is a token so both palettes
   resolve as a set; a literal hex outside the two token blocks (and the print
   block) is a bug. `color-scheme` stops the browser painting form controls in
   the other scheme underneath the page.

   Anything a single page needs and no other page does belongs in that page's
   own <style> block, not here. */

:root {
  color-scheme: light;

  --bg: #f6f1e7;
  --card: #fffdf7;
  --card-2: #fbf7ee;
  --border: #ddd5c7;
  --border-soft: #ebe4d7;
  --ink: #2c2823;
  --ink-soft: #6d6659;
  --ink-faint: #9a9184;
  --accent: #b4552f;
  --accent-ink: #ffffff;
  --good: #3f7d52;
  --warn: #a8762a;
  --on-ink: #fdf9f1;        /* text on an --ink surface: selected chip, toast */
  --link: #8f4526;
  --accent-hover: #9d4826;
  --hover-soft: #f2ece0;
  --danger: #8d3030;
  --danger-border: #e0bdbd;
  --danger-soft: #f6ecec;
  --stub-border: #e0c69a;
  --stub-bg: #fbf1dd;
  --note-bg: #fbf4e6;
  --note-ink: #6a5636;
  --toast-error: #7d2f2f;

  --shell-h: 52px;
  --radius: 12px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }

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

/* ---------- accessibility: motion, colour scheme, skip link ------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #1c1a17;
    --card: #262320;
    --card-2: #2d2a26;
    --border: #423d36;
    --border-soft: #34302b;
    --ink: #ece6db;
    --ink-soft: #b8b0a2;
    --ink-faint: #8a8276;
    --accent: #d9825a;
    --accent-ink: #1c1a17;
    --good: #6fbf85;
    --warn: #e0a94f;
    --on-ink: #1c1a17;
    --link: #e39a72;
    --accent-hover: #e4956e;
    --hover-soft: #34302b;
    --danger: #ef8f8f;
    --danger-border: #6a3a3a;
    --danger-soft: #3a2626;
    --stub-border: #6a5528;
    --stub-bg: #3a3120;
    --note-bg: #322b1f;
    --note-ink: #e3cf9f;
    --toast-error: #a33c3c;
  }
}

/* The first thing a keyboard or screen-reader user reaches, so it can jump
   straight past the language toggle and the app bar shell.js injects ahead of
   it. Off-screen until it receives focus. */
.skip-link {
  position: absolute;
  top: -60px;
  left: 8px;
  z-index: 300;
  background: var(--ink);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 8px;
  text-decoration: none;
  font-size: .9rem;
}
.skip-link:focus {
  top: calc(var(--safe-t) + 8px);
}

/* Flex column so the credit footer (.credit, injected by shell.js as the
   last body child on every page) can push itself to the bottom of the
   viewport via margin-top:auto when a page's own content is shorter than
   the screen, and simply follow the content in normal flow otherwise. The
   100vh fallback keeps older browsers that do not understand dvh at a
   still-correct full-viewport height. */
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  padding-left: var(--safe-l);
  padding-right: var(--safe-r);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

h1, h2, h3 { line-height: 1.2; margin: 0 0 .4em; }
h1 { font-size: 1.75rem; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .8em; }
a { color: var(--link); }

/* ---------- language bar (injected by shell.js above the app bar) -------- */

.langbar {
  display: flex;
  justify-content: flex-end;
  padding: calc(var(--safe-t) + 6px) 12px 0;
  background: var(--bg);
}
.langbar + .appbar { padding-top: 6px; height: calc(var(--shell-h) + 6px); }

.langbar__group {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--card);
}

.langbar__btn {
  font: inherit;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .04em;
  padding: 4px 10px;
  /* 44px hit area on a 16px-tall glyph: the box grows through padding, the
     text stays the size it was. */
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.langbar__btn + .langbar__btn { border-left: 1px solid var(--border); }
.langbar__btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

/* ---------- app bar (injected by shell.js on every page but index) ------- */

.appbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 10px;
  height: calc(var(--shell-h) + var(--safe-t));
  padding: var(--safe-t) 12px 0;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.appbar__back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--card-2);
  color: var(--ink);
  text-decoration: none;
}
.appbar__back svg { width: 18px; height: 18px; }
.appbar__back:hover { background: var(--hover-soft); }

.appbar__title {
  font-size: 1rem;
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.appbar__title .sub {
  color: var(--ink-soft);
  font-weight: 400;
  font-size: .85rem;
  margin-left: 8px;
}

/* ---------- layout ------------------------------------------------------ */

.wrap {
  max-width: 940px;
  margin: 0 auto;
  padding: 20px 16px calc(40px + var(--safe-b));
}
.wrap--narrow { max-width: 720px; }

.page-head { margin-bottom: 18px; }
.page-head p { color: var(--ink-soft); }

.sec {
  font-size: .78rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 26px 0 10px;
}

/* ---------- cards and tiles -------------------------------------------- */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.grid {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}
@media (min-width: 560px) { .grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 880px) { .grid--3 { grid-template-columns: 1fr 1fr 1fr; } }

.tile {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent, var(--border));
  border-radius: var(--radius);
  padding: 13px 14px;
  color: inherit;
  text-decoration: none;
}
.tile:hover { background: var(--card-2); }
.tile:focus-visible { outline: 2px solid var(--accent, var(--ink)); outline-offset: 2px; }
.tile__glyph {
  flex: 0 0 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  font-size: 1.35rem;
  background: var(--card-2);
}
.tile__body { min-width: 0; }
.tile__body h3 { margin: 0 0 2px; }
.tile__body p { margin: 0; color: var(--ink-soft); font-size: .9rem; }

/* ---------- recipe cards ------------------------------------------------ */

.rcard {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 14px;
  color: inherit;
  text-decoration: none;
  min-height: 118px;
}
.rcard:hover { background: var(--card-2); }
.rcard:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.rcard h3 { margin: 0 0 6px; padding-right: 28px; }
.rcard__meta { margin-top: auto; color: var(--ink-soft); font-size: .85rem; }

/* ---------- chips ------------------------------------------------------- */

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
/* display:flex above is author-origin and beats the UA sheet's [hidden] rule,
   so a filter row hidden by script needs this to actually disappear. */
.chips[hidden] { display: none; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--ink-soft);
  border-radius: 999px;
  /* A chip is a control reached with one thumb, often standing at a counter.
     The pill itself stays small enough to read as a label rather than a button,
     but the tappable box is padded out to the 44px a phone needs. */
  min-height: 44px;
  padding: 11px 12px;
  font-size: .8rem;
  font-family: inherit;
  line-height: 1.4;
  cursor: pointer;
}
.chip[aria-pressed="true"], .chip.is-on {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--on-ink);
}
.chip--static { cursor: default; }
.chip--stub { border-color: var(--stub-border); background: var(--stub-bg); color: var(--warn); }

/* A link to a side dish's own page, on a recipe card. Chip-shaped so it reads
   as one of a short row rather than as running prose, but it is a link and
   keeps a link's colour and underline on hover so it is obviously tappable. */
.side-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
  margin: 2px 4px 2px 0;
  font-size: .8rem;
  text-decoration: none;
  color: var(--link, var(--ink));
  background: var(--card);
}
.side-link:hover,
.side-link:focus-visible { text-decoration: underline; }
.side-link__icon { font-style: normal; }

/* ---------- buttons and inputs ----------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  padding: 8px 15px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: .95rem;
  cursor: pointer;
  text-decoration: none;
}
/* Same reason as .chips[hidden]: display:inline-flex above is author-origin
   and beats the UA sheet's [hidden] rule, so a button a page hides by
   attribute (mine.html's delete/undo pair, recipe.html's photo reset) needs
   this to actually disappear. */
.btn[hidden] { display: none; }
.btn:hover { background: var(--card-2); }
.btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { background: var(--accent-hover); }
.btn--danger { color: var(--danger); border-color: var(--danger-border); }
.btn[disabled] { opacity: .5; cursor: default; }
/* 44px hit area kept by padding rather than by growing the text, so a row of
   small buttons still reads as small. */
.btn--sm { min-height: 44px; padding: 8px 10px; font-size: .85rem; }

.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.field { display: block; margin: 0 0 12px; }
.field > span {
  display: block;
  font-size: .8rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 4px;
}

input[type="text"], input[type="search"], input[type="number"], select, textarea {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 11px;
}
textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ---------- checkable lists -------------------------------------------- */

.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { border-bottom: 1px solid var(--border-soft); }
.checklist li:last-child { border-bottom: 0; }

/* The whole label is the tap target, so it carries the 44px rather than the
   box: a ticked-off ingredient with wet hands should not need aiming at an
   18px square, and growing the drawn box instead would make every list look
   like a form. */
.check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  min-height: 44px;
  padding: 12px 2px;
  cursor: pointer;
}
.check input { margin: 3px 0 0; width: 18px; height: 18px; flex: 0 0 18px; accent-color: var(--accent); }
.check.is-done > .check__text { color: var(--ink-faint); text-decoration: line-through; }
.check__text { min-width: 0; }

/* ---------- misc -------------------------------------------------------- */

/* The × that removes one line from a list. Shared by the shopping list and the
   planner, so it lives here rather than in either page. */
.drop {
  border: 0;
  background: none;
  color: var(--ink-faint);
  font: inherit;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  /* 44px square. This is the control that deletes a line, reached with one
     thumb, often with wet hands, and the old 24x22 box put a mis-tap one pixel
     away from removing the wrong ingredient. */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 2px 6px;
  border-radius: 6px;
}
.drop:hover { color: var(--danger); background: var(--danger-soft); }

.empty {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 22px 18px;
  text-align: center;
  color: var(--ink-soft);
  background: var(--card-2);
}

.note {
  border-left: 3px solid var(--warn);
  background: var(--note-bg);
  border-radius: 0 8px 8px 0;
  padding: 10px 12px;
  color: var(--note-ink);
  font-size: .93rem;
}

.foot {
  margin-top: 34px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  color: var(--ink-faint);
  font-size: .85rem;
}

/* ---------- credit (injected by shell.js, last on every page) ----------- */
/* var(--ink-soft) clears 4.5:1 against var(--bg) in both palettes (measured:
   ~5.0:1 light, ~8.1:1 dark) — var(--ink-faint), used elsewhere for muted
   labels, does not. */
.credit {
  margin-top: auto;
  padding: 16px 16px calc(16px + var(--safe-b));
  text-align: center;
  font-size: .85rem;
  color: var(--ink-soft);
}
.credit a { color: var(--link); margin-left: 4px; }

.muted { color: var(--ink-soft); }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

#installBtn { display: none; }
#installBtn.is-ready { display: inline-flex; }
.offline-note { display: none; }
.offline-note.is-on { display: block; }

/* Storage failures must be visible: a save that quietly vanished is the one
   failure mode this app cannot recover from. */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + var(--safe-b));
  transform: translateX(-50%);
  max-width: min(92vw, 460px);
  background: var(--ink);
  color: var(--on-ink);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: .92rem;
  z-index: 100;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .22);
}
.toast--error { background: var(--toast-error); color: #fdf9f1; }

/* ---------- print: a recipe card, not a screenshot of the app -----------
   Shared by all five pages, so everything here is either page-neutral (colour,
   furniture, page breaks) or hangs off a selector only recipe.html has
   (.r-head, .cols). The other four pages lose their chrome and print as plain
   black-on-white lists, which is what they were doing before. */
@media print {
  /* No navigation, no controls, no transient chrome of any kind. */
  .appbar, .langbar, .btn, .chip, .no-print, .toast, .foot, .credit, .drop,
  .offline-note, #installBtn { display: none !important; }

  html, body {
    background: #fff;
    color: #000;
    font-size: 11.5pt;
  }
  .wrap { max-width: none; padding: 0; }
  .card, .rcard { border: 0; box-shadow: none; background: none; padding: 0; }
  a { color: #000; text-decoration: none; }

  /* The header rule: the name across the top, with region, time and servings
     sitting under it as a line of facts. */
  .r-head {
    border-bottom: 1.5pt solid #000;
    margin-bottom: 12pt;
    padding-bottom: 6pt;
  }
  .r-head h1 { font-size: 20pt; margin: 0 0 4pt; }
  .r-line { color: #000; font-size: 10pt; }
  .chips { display: block; }
  /* The static chips on a recipe carry its region, its categories and its cook
     time. Hiding every .chip threw those off the printed card, which is the one
     copy a cook takes into a kitchen with no phone in it. Only the static ones
     come back, and flat rather than as pills, so they read as a line of facts
     and not as controls someone might try to press on paper. The interactive
     chips on the browse page stay hidden by the rule above. */
  .chip--static {
    display: inline !important;
    background: none;
    border: 0;
    min-height: 0;
    padding: 0 10px 0 0;
    color: #000;
    font-size: 10pt;
  }

  /* Ingredients beside the method. A two-column grid rather than CSS columns:
     multi-column reflows both lists when the page breaks and can strand the
     ingredients halfway down page two, while a grid keeps each list in its own
     track across the break. */
  .cols { display: grid; grid-template-columns: 34% 1fr; gap: 0 18pt; align-items: start; }
  .cols h2 { font-size: 12pt; letter-spacing: .04em; text-transform: uppercase; }

  /* Nothing splits across a page in the middle of an ingredient or a step. */
  .checklist li, .steps li { break-inside: avoid; page-break-inside: avoid; border: 0; }
  .check { min-height: 0; padding: 1pt 0; }
  .check input { accent-color: #000; }
  .check.is-done > .check__text { color: #000; text-decoration: none; }
  .steps .check__text::before { background: none; border: 1pt solid #000; color: #000; }
  .note { background: none; color: #000; }
  .muted, .progress { color: #000; }
}
