/* niximacco-recipes
   ------------------------------------------------------------------------
   One stylesheet for the whole site, served under a name that contains a hash
   of its contents so it is fetched once and then never again.

   It is written as tokens first and components second. Anything a page wants
   to look different about should be a variable here rather than a style
   attribute there, because these pages are read on a phone in a shop and on a
   laptop at a table, and those two want the same decisions made once. */

/* ---------------------------------------------------------------- tokens */

:root {
  color-scheme: light dark;

  /* Surfaces, furthest to nearest. Four of them rather than two: a page, the
     cards on it, the things that sit on a card, and a well for the things
     that sit under one. A single --card meant every panel was the same
     colour as the thing inside it. */
  --bg: #f6f4f1;
  --surface: #ffffff;
  --raised: #faf8f6;
  --sunken: #f0edea;

  --text: #1a1815;
  --muted: #736c64;
  --faint: #9c948b;
  --line: #e6e1db;
  --line-strong: #d3ccc3;

  /* Warm rather than black. This is a cookbook; the old accent was #1d1d1f,
     which is correct and says nothing. */
  --accent: #b1442a;
  --accent-hover: #963620;
  --accent-text: #ffffff;
  --accent-weak: #fbeeea;
  --accent-line: #f0d5cc;

  --error-bg: #fceceb;
  --error-text: #a02d1e;
  --ok-bg: #e9f4ec;
  --ok-text: #1c6b39;
  --warn-bg: #fdf2e0;
  --warn-text: #855313;

  /* One radius scale, one shadow scale. */
  --r-sm: 8px;
  --r-md: 11px;
  --r-lg: 16px;
  --r-xl: 22px;
  --r-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(26, 24, 21, 0.05);
  --shadow-md: 0 1px 3px rgba(26, 24, 21, 0.06), 0 6px 16px -6px rgba(26, 24, 21, 0.10);
  --shadow-lg: 0 2px 6px rgba(26, 24, 21, 0.07), 0 18px 40px -18px rgba(26, 24, 21, 0.20);

  /* A serif for the things that are the recipe, a system stack for the things
     that are the software. It costs nothing to load and it is most of the
     difference between this looking like a cookbook and looking like a form. */
  --font-display: ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --page: 980px;
  --gutter: 28px;

  /* Tapping. 44px is the smallest thing a thumb hits reliably, and this list
     is used one-handed while holding something else. */
  --tap: 44px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16150f;
    --surface: #1e1d19;
    --raised: #26241f;
    --sunken: #131210;

    --text: #f3f0ea;
    --muted: #a49c91;
    --faint: #7d766c;
    --line: #322f29;
    --line-strong: #43403a;

    --accent: #e8825f;
    --accent-hover: #f0977a;
    --accent-text: #1a1005;
    --accent-weak: #2b1d16;
    --accent-line: #46291d;

    --error-bg: #3a1d19;
    --error-text: #ffb3a5;
    --ok-bg: #162c1f;
    --ok-text: #8fd6a6;
    --warn-bg: #33270f;
    --warn-text: #f0cd8a;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 1px 3px rgba(0, 0, 0, 0.45), 0 6px 16px -6px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 2px 6px rgba(0, 0, 0, 0.5), 0 18px 40px -18px rgba(0, 0, 0, 0.75);
  }
}

/* ------------------------------------------------------------------ base */

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  padding: var(--gutter) var(--gutter) 64px;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 var(--font-body);
  -webkit-font-smoothing: antialiased;
}

/* Signed out pages are a single centred card; signed in pages are a page. */
body.centred {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-bottom: var(--gutter);
}

main {
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  padding: 34px;
  box-shadow: var(--shadow-md);
}

main.wide {
  max-width: var(--page);
  padding: 32px 34px 38px;
}

h1, h2, h3 { color: var(--text); }

h1 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.015em;
}

h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

p { margin: 0 0 20px; color: var(--muted); font-size: 15px; }
p.tight { margin-bottom: 8px; }

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

strong { font-weight: 650; }

/* Amounts, counts and dates line up in a column when they are tabular. */
.amount, .num, .count, .amount-alt { font-variant-numeric: tabular-nums; }

/* The recipe's other way of saying the same amount. It reads as an aside
   because that is what it is: one measurement is what you reach for, and the
   second one is there for whichever of the two your scales are marked in. */
.amount-alt { color: var(--muted); font-size: 0.92em; }

::selection { background: var(--accent-weak); color: var(--text); }

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

/* ----------------------------------------------------------------- icons */

/* Font Awesome is loaded from a kit, which may not be configured. Everything
   is labelled in words as well, so a missing kit is a site without icons
   rather than a site with holes in it. The fixed box keeps a label in the
   same place either way. */
.ico {
  display: inline-block;
  width: 1.05em;
  text-align: center;
  flex: none;
}

.ico-accent { color: var(--accent); }
.ico-muted { color: var(--faint); }
.ico-lg { font-size: 1.15em; }

/* ------------------------------------------------------------------- nav */

.bar {
  width: 100%;
  max-width: var(--page);
  margin: 0 auto 22px;
}

/* One row, always. The bar carries a name, six links and an account, and a
   second row of chrome above every page costs more than the address it was
   wrapping to fit. The account is what gives way: it shortens to the name
   before the @ and truncates from there. */
nav {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 4px;
  padding: 7px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 12px 0 8px;
  margin-right: 4px;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}

.brand .ico { color: var(--accent); font-size: 17px; }
.brand:hover { color: var(--text); }

nav a.tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--r-sm);
  font-size: 14px;
  font-weight: 550;
  text-decoration: none;
  color: var(--muted);
  white-space: nowrap;
  transition: background 0.12s ease, color 0.12s ease;
}

nav a.tab:hover { background: var(--sunken); color: var(--text); }

nav a.tab.on {
  background: var(--accent-weak);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent-line);
}

nav .spacer { flex: 1; }

nav a.who { text-decoration: none; }
nav a.who:hover, nav a.who.on { color: var(--text); }

nav .who {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  padding: 0 6px;
  font-size: 13px;
  color: var(--faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* The last thing in the bar, and the one the flexbox squeezes first. It keeps
   its width so "Sign out" stays on one line. */
nav form { margin: 0; flex: none; }
nav form button { white-space: nowrap; }

/* The bottom bar a phone gets instead of the top one. */
.tabbar { display: none; }

/* ----------------------------------------------------------------- forms */

label {
  display: block;
  margin-bottom: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

input[type=email], input[type=text], input[type=url], input[type=number],
input[type=date], input[type=search], input[type=tel], select, textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 11px 13px;
  margin-bottom: 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--raised);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  transition: border-color 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

input::placeholder, textarea::placeholder { color: var(--faint); }

input:hover, select:hover, textarea:hover { border-color: var(--muted); }

input:focus, select:focus, textarea:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-weak);
}

textarea { min-height: 220px; resize: vertical; font-size: 14px; line-height: 1.6; }

/* A search field with the magnifying glass inside it. */
.search { position: relative; }

.search .ico {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--faint);
  pointer-events: none;
}

.search input { padding-left: 40px; margin-bottom: 0; }

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

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 11px 18px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: var(--accent);
  color: var(--accent-text);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease,
              box-shadow 0.12s ease, transform 0.06s ease;
}

button:hover { background: var(--accent-hover); }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.45; cursor: default; transform: none; }
button.block { width: 100%; }

button.quiet {
  min-height: 38px;
  padding: 9px 15px;
  background: var(--surface);
  color: var(--text);
  border-color: var(--line-strong);
  font-size: 14px;
  font-weight: 550;
  box-shadow: var(--shadow-sm);
}

button.quiet:hover { background: var(--raised); border-color: var(--muted); }

/* On a card and in a list row, a quiet button is already inside a surface, so
   it stops floating and just draws its own edge. */
.card button.quiet, .shop button.quiet { box-shadow: none; }

button.link {
  min-height: 0;
  width: auto;
  padding: 4px 2px;
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 550;
  text-decoration: underline;
  text-underline-offset: 2px;
}

button.link:hover { background: none; color: var(--accent); }

button.danger { color: var(--error-text); }
button.danger:hover { color: var(--error-text); }

/* A row of controls that should wrap rather than overflow on a phone. */
.actions-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* --------------------------------------------------------------- banners */

.banner {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 13px 15px;
  margin-bottom: 20px;
  border-radius: var(--r-md);
  font-size: 14.5px;
  line-height: 1.5;
  background: var(--error-bg);
  color: var(--error-text);
}

.banner .ico { margin-top: 3px; }

/* Several banners carry a button beside the words. The basis is what makes the
   button drop to its own line rather than squeezing the sentence into a column
   three words wide on a phone. */
.banner { flex-wrap: wrap; }
.banner > span { flex: 1 1 240px; }
.banner a { color: inherit; font-weight: 600; }
.banner.ok { background: var(--ok-bg); color: var(--ok-text); }
.banner.warn { background: var(--warn-bg); color: var(--warn-text); }
.banner ul { margin: 6px 0 0; padding-left: 18px; }

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

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding-top: 20px;
  margin-top: 26px;
  border-top: 1px solid var(--line);
}

.row form { margin: 0; }

.who { font-size: 13px; color: var(--faint); overflow-wrap: anywhere; }
.muted-small { font-size: 13.5px; color: var(--muted); }

.list-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin: 34px 0 6px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
}

.list-head h1, .list-head h2 { margin: 0; }
.list-head h2 { display: flex; align-items: center; gap: 9px; }
.list-head h2 .ico { color: var(--accent); font-size: 15px; }
.list-head.plain { border-bottom: 0; padding-bottom: 0; }
.list-head.first { margin-top: 0; }

.empty {
  margin: 16px 0 0;
  padding: 26px 20px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-lg);
  background: var(--raised);
  font-size: 14.5px;
  color: var(--muted);
  text-align: center;
}

.empty .ico { display: block; width: auto; font-size: 24px; color: var(--faint); margin-bottom: 10px; }

.fields { display: flex; gap: 16px; }
.fields > div { flex: 1; min-width: 0; }

/* ---------------------------------------------------------------- sheets */

/* A form opened over the page it was asked from. There is one of these: the
   plan that has to exist before a recipe can go on it. It is a <dialog> rather
   than a div with a z-index because the browser already knows how to trap the
   focus, close on escape, and paint the backdrop, and none of that is worth
   writing again here. */

dialog.sheet {
  width: min(560px, calc(100vw - 32px));
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}

dialog.sheet::backdrop { background: rgba(26, 24, 21, 0.42); }

dialog.sheet h2 {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 8px;
}

dialog.sheet form { margin: 0; }

/* ----------------------------------------------------------------- pills */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin: 2px 5px 2px 0;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--raised);
  color: var(--muted);
  font-size: 12px;
  font-weight: 550;
  line-height: 18px;
  text-decoration: none;
  white-space: nowrap;
  vertical-align: middle;
  transition: border-color 0.12s ease, background 0.12s ease, color 0.12s ease;
}

a.pill:hover { border-color: var(--muted); color: var(--text); }
.pill.on { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.pill.pantry { background: var(--warn-bg); color: var(--warn-text); border-color: transparent; }
.pill.low { background: var(--error-bg); color: var(--error-text); border-color: transparent; }

/* A pill that is really a button: "Add a recipe" at the top of a list. */
a.pill.action {
  min-height: 38px;
  padding: 8px 15px;
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-text);
  font-size: 14px;
  font-weight: 600;
}

a.pill.action:hover { background: var(--accent-hover); color: var(--accent-text); }

/* -------------------------------------------------------------- the shop */

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

.shop li {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  min-height: var(--tap);
  padding: 12px 4px;
  border-bottom: 1px solid var(--line);
  font-size: 15.5px;
  transition: opacity 0.15s ease;
}

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

/* The box is what a thumb is aiming at in a shop, so it is bigger than a form
   checkbox and has room around it. */
.shop input[type=checkbox] {
  width: 22px;
  height: 22px;
  margin: 1px 0 0;
  flex: none;
  accent-color: var(--accent);
  cursor: pointer;
}

/* How many of a thing, changed where it is written rather than by taking the
   line off and putting it back on. A text box rather than a number spinner,
   because "3 bags" is as good an answer as "3". */
.shop .qty {
  width: 74px;
  min-height: 34px;
  margin: 0;
  padding: 6px 9px;
  flex: none;
  font-size: 13.5px;
  text-align: center;
}

.shop .what { flex: 1; min-width: 0; }
.shop .amount { font-weight: 650; }
.shop .from { display: block; margin-top: 2px; font-size: 12.5px; color: var(--faint); }
.shop li.done .what { opacity: 0.42; text-decoration: line-through; }

/* One shop's worth of a plan, drawn as its own panel so a list split across
   three shops reads as three lists rather than one long one. */
.shop-group {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  overflow: hidden;
}

.shop-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 13px 16px;
  background: var(--raised);
  border-bottom: 1px solid var(--line);
}

.shop-head .name {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text);
}

.shop-head .name .ico { color: var(--accent); }
.shop-group > .shop { margin: 0; padding: 4px 16px; }

/* How much of a shop is in the trolley. */
.meter {
  width: 100%;
  height: 5px;
  margin-top: 10px;
  border-radius: var(--r-pill);
  background: var(--sunken);
  overflow: hidden;
}

.meter > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.25s ease;
}

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

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  text-decoration: none;
  transition: box-shadow 0.16s ease, transform 0.16s ease, border-color 0.16s ease;
}

.card:hover, .card:focus-within {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.card .body { display: flex; flex-direction: column; flex: 1; padding: 15px 16px 16px; }
.card h3 { margin: 0 0 5px; font-family: var(--font-display); font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.card h3 a { color: var(--text); text-decoration: none; }
.card .meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; color: var(--faint); }
.card .meta .ico { font-size: 11px; }
.card .tags { margin-top: 10px; }
.card .spacer { flex: 1; min-height: 10px; }
.card.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow-md); }

/* A recipe's photograph on a card. A fixed ratio rather than a fixed height,
   so a grid of cards has its titles on the same line. */
.card .photo {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: var(--sunken);
  margin: 0;
  border-radius: 0;
}

/* A card with no photograph still gets a band, so a mixed grid does not look
   like two different kinds of thing. */
.card .noshot {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 16 / 10;
  background: linear-gradient(140deg, var(--sunken), var(--raised));
  color: var(--faint);
  font-size: 26px;
}

/* Anywhere on the card opens the recipe. The title's own link is stretched
   over the whole thing rather than the card being wrapped in one, so there is
   still exactly one link on it and one place for a keyboard to land - a card
   that was a link with a button inside it would be neither. */
.card h3 a::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.card button { position: relative; z-index: 1; }

/* ---------------------------------------------------------------- tables */

.scroll {
  overflow-x: auto;
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
}

table { width: 100%; border-collapse: collapse; font-size: 14.5px; }

th {
  padding: 12px 14px;
  background: var(--raised);
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  white-space: nowrap;
}

td { padding: 13px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--raised); }
td.actions { white-space: nowrap; text-align: right; }
td.actions button { margin-left: 10px; }
select.inline { width: auto; min-height: 34px; margin: 0; padding: 6px 10px; font-size: 13px; }

/* A column holding nothing but a dropdown, sized by what is in it. The units
   and the two class names are words - "package", "handful", "Per-recipe" - and
   a column pinned to a guessed pixel width cuts the longer ones off mid-word,
   which leaves a column of measurements that cannot be told apart at a glance.
   A select left to size itself is as wide as its widest option; width:1% is
   what makes the column shrink-wrap to that rather than to the guess, and the
   room it does not take goes to the ingredient and note fields, which can
   always use it. */
.col-pick { width: 1%; white-space: nowrap; }

/* The amount is "1 1/2" at its longest, and reads better in a box that size
   than in one stretched across a third of the table. */
.col-amount { width: 76px; }

/* A control that repeats under the table it belongs to, sitting close enough
   to the last row to read as part of the list rather than as the next thing. */
.under-list { margin: 10px 0 0; }

/* A step of the method, as it is edited: its number, the words, and the way to
   take it out. Grid rather than a row of boxes because on a phone those three
   stop being a row - the words take the width and the rest goes under them. */
#steps { counter-reset: step-row; }

.step-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: start;
  margin-bottom: 8px;
  counter-increment: step-row;
}

/* Numbered here and nowhere in the data: a step's number is its position, and
   the only reason to draw it is so that a method being corrected on a small
   screen can be read against the one on the recipe page. */
.step-row::before {
  content: counter(step-row);
  min-width: 14px;
  padding-top: 13px;
  color: var(--faint);
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.step-row textarea { min-height: 58px; margin: 0; }
.step-row button { margin-top: 10px; }

/* ----------------------------------------------------- recipes and steps */

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

ol.steps li {
  position: relative;
  margin-bottom: 4px;
  padding: 4px 0 14px 42px;
  counter-increment: step;
}

/* The number is drawn rather than left to the list marker, because a step can
   be ticked off while cooking and a marker cannot be styled to match. */
ol.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 27px;
  height: 27px;
  border-radius: var(--r-pill);
  background: var(--accent-weak);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

ol.steps li:target { background: var(--warn-bg); border-radius: var(--r-md); box-shadow: 0 0 0 8px var(--warn-bg); }

ul.plain { margin: 10px 0 0; padding: 0; list-style: none; }
ul.plain li { padding: 9px 2px; border-bottom: 1px solid var(--line); font-size: 15.5px; }
ul.plain li:last-child { border-bottom: 0; }

.heading {
  margin: 20px 0 2px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--faint);
}

/* A recipe's photograph on its own page. Capped rather than left to the file's
   own size: these come off a phone, and a four thousand pixel wide picture
   would otherwise set the layout. */
.photo {
  display: block;
  width: 100%;
  max-height: 400px;
  object-fit: cover;
  border-radius: var(--r-lg);
  margin: 0 0 22px;
  background: var(--sunken);
}

/* Serves / prep / cooking, as three facts rather than a sentence of middots. */
.facts { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0 0; padding: 0; list-style: none; }

.facts li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--raised);
  font-size: 13.5px;
  color: var(--text);
}

.facts .ico { color: var(--accent); }
.facts .label { color: var(--muted); }

/* The recipe page on a wide screen: the ingredients stay on screen while the
   method is scrolled, because that is the pair of things being read together.
   Below the breakpoint it is one column in the order it is written. */
.recipe-cols { display: block; }

@media (min-width: 900px) {
  .recipe-cols {
    display: grid;
    grid-template-columns: minmax(0, 300px) minmax(0, 1fr);
    gap: 40px;
    align-items: start;
    margin-top: 8px;
  }

  .recipe-cols .rail { position: sticky; top: 22px; }
  .recipe-cols .rail .list-head { margin-top: 0; }
  .recipe-cols .method .list-head { margin-top: 0; }
}

/* Reading a recipe and cooking one want different ingredient lists. Reading
   it asks what is in this and what do we need - one list, read top to
   bottom. Cooking it asks what goes in the pan next and what goes in with
   it, which is that same list broken at every step.

   So the breaks are always rendered and only drawn while cooking. Outside
   it the wrappers collapse and the borders run straight through them,
   leaving a plain list that happens to be in the order the method reaches
   for things. */
.runs { margin: 8px 0 0; }
.runs ul.plain { margin: 0; }
.runs .run:not(:last-child) ul.plain li:last-child { border-bottom: 1px solid var(--line); }
.run { position: relative; }
.run .tie { display: none; }

/* Convert units sits under the ingredients it adds to. The rail it is in is
   300px on a wide screen and the whole width on a phone, so the button and the
   sentence about it wrap onto two lines rather than being squeezed onto one. */
.convert { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 16px; }
.convert .muted-small { flex: 1 1 200px; }

/* --------------------------------------------------------------- cooking */

/* Cooking mode. The recipe is the only thing on screen, the type is big
   enough to read from across a worktop, and the steps can be ticked off.
   None of it touches the recipe - a tick is a fact about tonight. */
body.cooking { padding: 0; background: var(--surface); }
body.cooking .bar, body.cooking .tabbar { display: none; }

/* !important because several of the things that step aside carry an inline
   display of their own, and an inline style beats a class every time. */
body.cooking .not-cooking { display: none !important; }

body.cooking main {
  max-width: 780px;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  padding: 24px 22px 110px;
}

/* One column on a worktop. The rail is for reading the recipe, not for
   cooking from it - while cooking, the list is the thing being worked
   through in order and it wants the full width. */
body.cooking .recipe-cols { display: block; }
body.cooking .recipe-cols .rail { position: static; }

body.cooking h1 { font-size: 32px; }
body.cooking h2 { font-size: 18px; }
body.cooking ul.plain li { padding: 12px 2px; font-size: 18px; }
body.cooking ol.steps { font-size: 19px; line-height: 1.6; }
body.cooking ol.steps li { margin: 0; padding: 14px 0 14px 46px; border-bottom: 1px solid var(--line); }
body.cooking ol.steps li:last-child { border-bottom: 0; }
body.cooking ol.steps li::before { top: 14px; width: 30px; height: 30px; font-size: 14px; }

/* Cooking. Ingredients that go into the pan at the same moment stand apart
   from the rest, tied by a rule down their left. A run of one is not drawn
   as a group - the rule means "these go in together", and it cannot mean
   that about a single thing. */
body.cooking .runs ul.plain { margin: 8px 0 0; }
body.cooking .runs .run:not(:last-child) ul.plain li:last-child { border-bottom: 0; }
body.cooking .run.tied { padding-left: 16px; }

body.cooking .run.tied::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: var(--r-pill);
  background: var(--accent-line);
}

body.cooking .run .tie {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 14px 0 -4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  text-decoration: none;
}

body.cooking .run .tie:hover { color: var(--accent-hover); }

/* The tick is only offered while cooking. Outside it the box is hidden and
   disabled, so the step text is text and nothing invisible can be toggled. */
ol.steps .tick { display: none; }
ol.steps label { display: block; }
body.cooking ol.steps label { display: flex; align-items: flex-start; gap: 16px; cursor: pointer; }

body.cooking ol.steps .tick {
  display: block;
  flex: none;
  width: 28px;
  height: 28px;
  margin: 1px 0 0;
  accent-color: var(--accent);
}

body.cooking ol.steps li.done .words { opacity: 0.38; text-decoration: line-through; }
body.cooking ol.steps li.done::before { background: var(--sunken); color: var(--faint); }

/* The bar along the bottom, where a thumb already is. */
.cook-bar { display: none; }

body.cooking .cook-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--line);
  box-shadow: 0 -6px 24px -12px rgba(0, 0, 0, 0.28);
}

.cook-bar .spacer { flex: 1; }

/* ---------------------------------------------------------------- phones */

@media (max-width: 900px) {
  :root { --gutter: 16px; }

  body { padding-bottom: calc(var(--tap) + 34px + env(safe-area-inset-bottom)); }
  body.centred { padding-bottom: var(--gutter); }

  main { padding: 22px 18px 26px; border-radius: var(--r-lg); }
  main.wide { padding: 22px 18px 26px; }

  h1 { font-size: 25px; }

  .fields { flex-direction: column; gap: 0; }

  dialog.sheet { padding: 20px; border-radius: var(--r-lg); }

  /* The top bar keeps the name and the way out; the links move to a bar along
     the bottom, where a thumb can reach them one-handed. The address goes
     entirely - there is only room for three or four letters of it here, and
     "som" identifies nobody. */
  nav a.tab { display: none; }

  /* The name goes with the links - there is only room for three or four
     letters of it here - leaving the icon, which is the way to the account
     page and the only thing in the bar that has to be reachable by thumb. */
  nav .who .name { display: none; }
  nav .who { padding: 0 4px; }
  nav { padding: 9px 12px; }

  .tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    display: flex;
    justify-content: space-around;
    gap: 2px;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 1px solid var(--line);
    box-shadow: 0 -6px 24px -14px rgba(0, 0, 0, 0.3);
  }

  .tabbar a {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: var(--tap);
    padding: 5px 2px;
    border-radius: var(--r-sm);
    font-size: 10.5px;
    font-weight: 600;
    color: var(--faint);
    text-decoration: none;
  }

  .tabbar a .ico { font-size: 17px; width: auto; }
  .tabbar a.on { color: var(--accent); background: var(--accent-weak); }

  /* A list row's controls go under the thing they act on rather than beside
     it, so nothing gets squeezed to two words per line. */
  .shop li { flex-wrap: wrap; }
  .shop li > button { margin-left: 35px; }

  /* Two columns on a phone rather than one. 145px is what it takes for a 375px
     screen to fit a pair, and browsing a cookbook is scanning rather than
     reading - two small cards beat one big one. */
  .cards { grid-template-columns: repeat(auto-fill, minmax(145px, 1fr)); gap: 12px; }
  .card .body { padding: 12px 13px 14px; }
  .card h3 { font-size: 15.5px; }

  /* ---------------------------------------------- filling a form by thumb */

  /* 16px rather than 15 for anything typed into. Below that, iOS zooms the
     page in on the field being tapped and leaves it there, so correcting two
     boxes in a row costs a pinch back out between them. */
  input[type=email], input[type=text], input[type=url], input[type=number],
  input[type=date], input[type=search], input[type=tel], select, textarea {
    font-size: 16px;
  }

  /* A dropdown sized to sit inside a table cell is not a target for a thumb. */
  select.inline { min-height: var(--tap); padding: 9px 12px; font-size: 16px; }

  /* A six-column table of text boxes is a fair way to correct an ingredient
     list at a table and a bad one in a hand: 375px split six ways leaves boxes
     two characters wide, and the note, the class and the way to remove a line
     all sit off the right-hand edge behind a sideways scroll nothing on the
     screen admits to. So each row becomes its own card, in the order the
     question is asked - how much, of what, and then the things that are
     usually already right. */
  .stack { overflow-x: visible; border: 0; background: none; }
  .stack table, .stack tbody, .stack tr, .stack td { display: block; }
  .stack thead { display: none; }
  .stack table { font-size: inherit; }

  .stack tbody tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 10px;
    margin-bottom: 12px;
    padding: 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
  }

  /* Hover on a touch screen is whatever was tapped last, and it sticks. */
  .stack tbody tr:hover { background: var(--surface); }

  .stack td { padding: 0; border: 0; }
  .stack td.wide { grid-column: 1 / -1; }
  .stack td input, .stack td select { width: 100%; }

  /* The column headings went with the thead, so each box carries its own. */
  .stack td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }

  .stack td.actions { align-self: end; }
  .stack td.actions button { min-height: var(--tap); margin: 0; padding: 4px 6px; }

  /* The words get the whole width; the number stays at the start of them and
     the way to remove the step goes underneath, where it is not something to
     be caught by a thumb reaching for the end of a sentence. */
  .step-row { grid-template-columns: auto 1fr; gap: 4px 10px; margin-bottom: 16px; }
  .step-row textarea { min-height: 104px; }

  .step-row button {
    grid-column: 2;
    justify-self: start;
    min-height: var(--tap);
    margin-top: 0;
    padding: 4px 6px;
  }

  /* The controls that put another row on a list are the ones most reached for
     while correcting one, and a 13px underline is not something to aim at. */
  button[data-add-line], button#add-step { min-height: var(--tap); padding: 4px 8px; font-size: 14px; }

  /* A quiet button is 38px, which is a fine target for a mouse. */
  .convert button { min-height: var(--tap); }
}

/* Anything that would move, for a person who has asked things not to. */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
  .card:hover, .card:focus-within { transform: none; }
}

/* Nothing here is meant for paper except a recipe, and that wants the page
   and none of the software around it. */
@media print {
  body { padding: 0; background: #fff; color: #000; }
  .bar, .tabbar, .cook-bar, .not-cooking, button { display: none !important; }
  main, main.wide { max-width: none; border: 0; box-shadow: none; padding: 0; }
  .recipe-cols { display: block; }
}
