/* Tangent. The brand's own values live in tokens.css (as supplied in
   tangent-brand/); this file names the jobs they do in the app. See BRAND.md.

   One family, Bricolage Grotesque, kept in the app so it works offline. */
@font-face {
  font-family: "Bricolage Grotesque";
  src: url("/fonts/bricolage-grotesque-latin.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}

/* Colours carry meaning: leaf is "from your kitchen" and keeping a card,
   tangerine text is "new", red is "ruled out". Tangerine fills mark what is
   chosen, with Ink text on them (never white). Main actions are Ink. The mood
   tints are decoration only. One light theme: the brand has no dark one. */
:root {
  --bg: var(--tg-bg);
  --surface: var(--tg-surface);
  --text: var(--tg-text);
  --muted: var(--tg-text-muted);
  --line: var(--tg-line);
  /* Orange text and links, readable on Pith. */
  --accent: var(--tg-tangerine-text);
  /* Main actions. */
  --fill: var(--tg-primary-bg);
  --on-fill: var(--tg-primary-fg);
  /* Whatever is chosen: a chip, a tile, the current tab. */
  --chosen: var(--tg-selected-bg);
  --on-chosen: var(--tg-selected-fg);
  --chosen-soft: #fde4d2;
  --leaf: var(--tg-leaf);
  --leaf-soft: #e4efe0;
  --new: var(--tg-tangerine-text);
  --no: #a04a3f;
  --no-soft: #f8e1dc;
  --edge: transparent;
  --shadow: 0 1px 2px rgb(42 26 16 / 0.06), 0 4px 14px rgb(42 26 16 / 0.07);
  --mood-any: #f3e8f1;
  --mood-comfort: #fde2cc;
  --mood-quick: #e3ecf4;
  --mood-light: #e4efe0;
  --mood-spicy: #fbdcd3;
  --mood-protein: #fbefc9;
  --display: var(--tg-font);
  --tabs-height: 3.5rem;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.5 var(--tg-font);
}

main {
  max-width: 34rem;
  margin: 0 auto;
  /* env() keeps content clear of the iPhone notch and home bar when installed. */
  padding: calc(1rem + env(safe-area-inset-top)) 1rem
    calc(var(--tabs-height) + 1rem + env(safe-area-inset-bottom));
}

h1,
h2 {
  font-family: var(--display);
  font-weight: var(--tg-weight-heavy);
  letter-spacing: var(--tg-tracking-tight);
  line-height: 1.15;
}

h1 {
  font-size: 1.7rem;
  margin: 0 0 1rem;
}

h2 {
  font-size: 1.25rem;
  margin: 1.5rem 0 0.5rem;
}

h3 {
  font-size: 1rem;
  margin: 1rem 0 0.25rem;
}

button {
  font: inherit;
  color: inherit;
  min-height: 44px; /* comfortable tap target */
  touch-action: manipulation; /* a quick second tap is a tap, not a zoom */
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--tg-radius-control);
  background: var(--surface);
}

button[aria-pressed="true"] {
  background: var(--chosen);
  border-color: var(--chosen);
  color: var(--on-chosen);
  font-weight: var(--tg-weight-heavy);
}

button:disabled {
  opacity: 0.6;
}

/* The main button: Ink, 52px tall. */
.primary {
  width: 100%;
  min-height: 52px;
  margin-top: 0.75rem;
  border-radius: var(--tg-radius-button);
  background: var(--fill);
  border-color: var(--fill);
  color: var(--on-fill);
  font-weight: var(--tg-weight-semibold);
}

.hint {
  color: var(--muted);
  font-size: 0.9rem;
}

.notice {
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  background: var(--surface);
}

/* Suggestions */

.filter {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

#filter-buttons {
  display: flex;
  gap: 0.5rem;
}

/* "Max. new ingredients": the brand's hero control. Pith chips, the chosen
   one Tangerine. */
#filter-buttons button {
  min-width: 52px;
  background: var(--bg);
  font-size: 1.1rem;
  font-weight: var(--tg-weight-semibold);
}

#filter-buttons button[aria-pressed="true"] {
  background: var(--chosen);
  font-weight: var(--tg-weight-heavy);
}

/* The deck: one card at a time, dragged sideways to decide.
   The Suggestions view is exactly as tall as the screen, so the page itself
   never scrolls; the card takes whatever height is left over. */

#view-suggestions {
  display: flex;
  flex-direction: column;
  /* dvh is the height of the visible screen, allowing for browser toolbars. */
  height: calc(
    100dvh - 2rem - var(--tabs-height) - env(safe-area-inset-top) - env(safe-area-inset-bottom)
  );
}

/* hidden must win over any display rule above, or a hidden view stays on screen. */
[hidden] {
  display: none !important;
}

#deck-status {
  min-height: 1.5em;
  margin: 0.4rem 0;
}

#deck {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow-x: clip; /* a card flying off must not widen the page */
}

.swipe-card {
  flex: 1;
  position: relative;
  perspective: 1200px; /* gives the flip its depth */
  transition: transform 0.18s ease-out;
}

.swipe-card.dragging {
  transition: none;
  user-select: none;
  -webkit-user-select: none;
}

/* The two faces sit back to back; turning .flip over shows the other one. */
.flip {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 0.4s;
}

.flipped > .flip {
  transform: rotateY(180deg);
}

.face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 1rem;
  overflow: hidden;
  border: 1px solid var(--edge);
  border-radius: var(--tg-radius-card);
  background: var(--surface);
  box-shadow: var(--shadow);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.swipe-card .front {
  touch-action: none; /* sideways drags are ours; the front never scrolls */
}

.back {
  transform: rotateY(180deg);
}

/* Only the side facing you takes touches. Without this, phones can deliver a
   touch to the hidden side, which then scrolls instead of the page or the swipe. */
.back,
.flipped > .flip > .front {
  pointer-events: none;
}

.flipped > .flip > .back {
  pointer-events: auto;
}

.face h2 {
  margin-top: 0;
}

.face p {
  margin: 0.4rem 0;
}

/* Long text is cut short on the front so the card always fits the screen. */
.face .description,
.face .why {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}

.flip-button {
  margin-top: auto;
  flex-shrink: 0;
  color: var(--accent);
}

.back h2 {
  margin-bottom: 0.5rem;
  flex-shrink: 0;
}

.card-tabs {
  display: flex;
  gap: 0.5rem;
}

.card-tabs button {
  flex: 1;
}

.panel {
  flex: 1;
  min-height: 0;
  margin: 0.5rem 0;
  overflow-y: auto;
  touch-action: pan-y; /* this part does scroll, inside the card */
  -webkit-overflow-scrolling: touch;
}

.panel li {
  margin-bottom: 0.4rem;
}

/* The front takes on the colour of the decision as it is dragged. */
.swipe-card[data-hint="plan"] .front {
  background: var(--leaf-soft);
  border-color: var(--leaf);
}

.swipe-card[data-hint="no"] .front {
  background: var(--no-soft);
  border-color: var(--no);
}

.swipe-card[data-hint="plan"]::before,
.swipe-card[data-hint="no"]::before {
  position: absolute;
  z-index: 1;
  top: 0.75rem;
  padding: 0.2rem 0.6rem;
  border: 2px solid currentColor;
  border-radius: 0.5rem;
  background: var(--surface);
  font-weight: 700;
}

.swipe-card[data-hint="plan"]::before {
  content: "To try";
  left: 0.75rem;
  color: var(--leaf);
}

.swipe-card[data-hint="no"]::before {
  content: "Not interested";
  right: 0.75rem;
  color: var(--no);
}
#deck-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

#deck-actions button {
  flex: 1;
  padding-inline: 0.4rem;
}

.primary-inline {
  border-radius: var(--tg-radius-button);
  background: var(--fill);
  border-color: var(--fill);
  color: var(--on-fill);
  font-weight: var(--tg-weight-semibold);
}

.link {
  min-height: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  text-decoration: underline;
}

/* The same two-sided card in the Plan lists. Here the front sits in the normal
   flow and sets the height; the back overlays it and scrolls inside. */

.list-card {
  margin-top: 1rem;
  perspective: 1200px;
}

.list-card .flip,
.list-card .front {
  position: relative;
  inset: auto;
}

.list-card .front {
  min-height: 20rem;
}

.list-card .actions {
  margin-top: 0.5rem;
}
.summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip {
  padding: 0.15rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  font-size: 0.9rem;
}

.new-items {
  margin: 0.5rem 0;
  padding: 0;
  list-style: none;
  color: var(--new);
}

.why {
  font-style: italic;
}

.tag {
  font-size: 0.8rem;
  color: var(--muted);
}

.tag-new {
  color: var(--new);
  font-weight: 600;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.to-buy {
  padding: 0;
  list-style: none;
}

.to-buy li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--line);
}

.to-buy button {
  display: block;
  margin-top: 0.4rem;
}

/* "Cooking for" control: minus, number, plus. */

.stepper {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.stepper button {
  min-width: 44px;
  font-size: 1.2rem;
}

/* Inside a card or the tour the control is centred or compact as suits. */
/* In the tour it matches the body text above it, in colour and size. */
.tour-slide .stepper {
  justify-content: center;
  margin-top: 0.5rem;
  color: var(--muted);
  font-size: 1.05rem;
}

.tour-slide .stepper button {
  font-size: 1.05rem;
}

.panel .stepper,
.cook-body .stepper {
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

.stepper strong {
  min-width: 1.2rem;
  text-align: center;
}

/* Plan: one compact row per recipe, opening to the full card. */

.row {
  border-bottom: 1px solid var(--line);
}

.row-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.row-name {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0.6rem 0;
  border: 0;
  border-radius: 0;
  background: none;
  text-align: left;
}

/* The switcher on Plan: four segments, the chosen one raised. */
.switcher {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.4rem;
  margin: 0 0 1rem;
}

.switcher button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  padding: 0.55rem 0.1rem 0.5rem;
  border-color: var(--edge);
  border-radius: var(--tg-radius-button);
  box-shadow: var(--shadow);
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.2;
}

.switcher .count {
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: var(--tg-weight-heavy);
  line-height: 1.1;
  color: var(--text);
}

.switcher button[aria-pressed="true"] {
  border-color: var(--chosen);
  background: var(--chosen);
  color: var(--on-chosen);
  font-weight: var(--tg-weight-semibold);
}

.switcher button[aria-pressed="true"] .count {
  color: var(--on-chosen);
}

/* A plain two-way switch, as at the top of the shopping list. */
.segmented {
  display: grid;
  grid-auto-columns: minmax(0, 1fr);
  grid-auto-flow: column;
  gap: 0.25rem;
  margin: 0 0 0.75rem;
  padding: 0.25rem;
  border-radius: 0.75rem;
  background: var(--line);
}

.segmented button {
  min-height: 40px;
  border: 0;
  border-radius: 0.6rem;
  background: none;
  color: var(--muted);
  font-size: 0.9rem;
}

.segmented button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
}

/* The line above the planned meals, with "Clear all" at its end. */
.list-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.list-heading .link {
  min-height: 44px;
  font-weight: 600;
  text-decoration: none;
}

/* The grip for dragging a row into a new place. */
.drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  min-height: 44px;
  flex-shrink: 0;
  color: var(--muted);
  font-size: 1.3rem;
  cursor: grab;
  touch-action: none; /* a drag from here moves the row, not the page */
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}

/* Rows slide aside smoothly; the one being dragged follows the finger exactly. */
.rows .row {
  transition: transform 0.12s ease-out;
}

.rows .row.moving {
  position: relative;
  z-index: 1;
  transition: none;
  background: var(--chosen-soft);
  border-radius: 0.6rem;
}

.row-quick {
  flex-shrink: 0;
  color: var(--accent);
  border-color: var(--accent);
  white-space: nowrap;
}

.row .list-card {
  margin: 0 0 1rem;
}

/* Pop-ups. The shopping list has a fixed top and bottom, and only the middle
   scrolls, so the close and share buttons never go out of reach. */

dialog {
  width: min(32rem, calc(100vw - 2rem));
  max-height: 85dvh;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--tg-radius-card);
  background: var(--surface);
  color: var(--text);
}

dialog::backdrop {
  background: rgb(0 0 0 / 0.5);
}

.sheet {
  padding: 0;
  overflow: hidden;
  border-radius: var(--tg-radius-sheet);
}

/* Only when open: setting display on a closed dialog would make it show. */
.sheet[open] {
  display: flex;
  flex-direction: column;
}

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

.dialog-head h2 {
  margin: 0;
}

.close {
  flex-shrink: 0;
  width: 44px;
  font-size: 1.1rem;
}

.dialog-body {
  flex: 0 1 auto;
  min-height: 0;
  max-height: calc(85dvh - 9.5rem); /* the pop-up's limit, less its top and bottom bars */
  padding: 0 1rem 1rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.dialog-foot {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--line);
}

.dialog-foot button {
  flex: 1;
}

/* The cog that opens Settings, in the top corner of every page. */

main {
  position: relative;
}

#open-settings {
  position: absolute;
  top: calc(0.6rem + env(safe-area-inset-top));
  right: 1rem;
  width: 44px;
  padding: 0;
  font-size: 1.2rem;
}

/* Room for the cog beside each page title. */
h1 {
  padding-right: 3.5rem;
}

/* "Back" controls: proper buttons, so they are easy to find. */
.back-button {
  margin-bottom: 0.25rem;
  font-weight: 600;
  color: var(--accent);
  border-color: var(--accent);
}

/* Overviews made of tiles fill the screen instead of leaving it half empty.
   A view with the class "fill" is at least as tall as the visible screen, and
   its tile grid stretches to use whatever height is left. */

.view.fill {
  display: flex;
  flex-direction: column;
  min-height: calc(
    100dvh - 2rem - var(--tabs-height) - env(safe-area-inset-top) - env(safe-area-inset-bottom)
  );
}

.fill-area {
  display: flex;
  flex-direction: column;
}

.view.fill > .fill-area,
#view-suggestions > .fill-area {
  flex: 1;
  min-height: 0;
}

.view.fill .category-grid,
#mood-tiles .category-grid {
  flex: 1;
  grid-auto-rows: 1fr; /* every row the same height, sharing the space */
}

.view.fill .category,
#mood-tiles .category {
  align-items: center;
  justify-content: center;
  text-align: center;
}

.view.fill .category-icon,
#mood-tiles .category-icon {
  font-size: 2.4rem;
}

/* Basket has eight tiles, so its tiles are a little tighter to fit one screen. */
#view-basket.fill .category {
  padding: 0.4rem;
  line-height: 1.25;
}

#view-basket.fill .category-icon {
  font-size: 1.9rem;
}

#basket-status {
  margin: 0.4rem 0;
}

/* On Suggestions the tiles start where the button starts on the other tabs. */
#mood-tiles .category-grid {
  margin-top: 0;
}

#basket-bought {
  margin-bottom: 0.5rem;
}

#basket-status:empty {
  display: none;
}

/* The deck, once a mood is chosen. */

#deck-pane {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

#deck-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  padding-right: 3.5rem; /* room for the cog */
}

#deck-head .back-button {
  flex-shrink: 0;
  margin: 0;
}

/* A typed steer can be long; it is cut short with dots, never wrapped. */
#deck-head strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* "Something specific": a slim button under the mood tiles, and its pop-up. */
.steer-button {
  flex-shrink: 0;
  margin-top: 0.6rem;
  color: var(--accent);
}

.steer-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.steer-chips button {
  min-height: 40px;
  padding: 0.3rem 0.75rem;
  border-radius: 1.25rem;
  font-size: 0.95rem;
}

#steer .add-extra button {
  flex-shrink: 0;
  background: var(--fill);
  border-color: var(--fill);
  color: var(--on-fill);
  font-weight: var(--tg-weight-semibold);
}

/* Buttons under an open recipe in Plan: one line, sharing the width. The
   first is the main action; the rest are outlines with no fill, so they sit
   on the page instead of floating as white blocks. */
.card-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.card-actions button {
  flex: 1;
  min-width: 0;
  padding: 0.4rem 0.3rem;
  background: none;
  font-size: 0.9rem;
  white-space: nowrap;
}

.card-actions .primary-inline {
  background: var(--fill);
}

.card-actions .quiet {
  flex: 0 1 auto;
  padding-inline: 0.8rem;
  color: var(--muted);
}

/* The shopping list page: its two main buttons stay at the bottom of the screen. */
.shop-foot {
  position: sticky;
  bottom: calc(var(--tabs-height) + env(safe-area-inset-bottom));
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  padding: 0.6rem 0;
  background: var(--bg);
  border-top: 1px solid var(--line);
}

.shop-foot button {
  flex: 1;
}

#view-shopping h3 {
  margin-top: 1.25rem;
}

/* Shopping list lines: tick to cross off, cross to remove. */

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

.shop-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-bottom: 1px solid var(--line);
}

.shop-line label {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 44px;
  padding: 0.4rem 0;
}

.shop-line input {
  flex-shrink: 0;
  width: 1.4rem;
  height: 1.4rem;
  accent-color: var(--tg-tangerine);
}

.shop-line.ticked label {
  color: var(--muted);
  text-decoration: line-through;
}

.shop-line .remove {
  flex-shrink: 0;
  width: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
}

.add-extra {
  display: flex;
  gap: 0.5rem;
}

.add-extra input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

/* Cook mode: one step at a time, full screen, in large text. */

#cook {
  position: fixed;
  inset: 0;
  z-index: 9;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: calc(1rem + env(safe-area-inset-top)) 1.25rem calc(1rem + env(safe-area-inset-bottom));
  background: var(--bg);
}

.cook-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  color: var(--muted);
}

.cook-progress {
  display: flex;
  gap: 0.25rem;
}

.cook-progress span {
  flex: 1;
  height: 0.3rem;
  border-radius: 0.15rem;
  background: var(--line);
}

.cook-progress .done {
  background: var(--chosen);
}

/* The step itself; it scrolls if a long step or the ingredient list needs it. */
.cook-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  touch-action: pan-y;
}

.cook-step {
  margin: 0.25rem 0 1rem;
  font-size: 1.5rem;
  line-height: 1.45;
}

.cook-buttons {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 0.5rem;
}

.cook-buttons button {
  min-height: 3.25rem;
  font-size: 1.1rem;
}

#cook > .link {
  align-self: center;
  min-height: 44px;
}

/* The closing card after a meal is cooked: centred, with room to breathe. */
.cooked-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.75rem;
  text-align: center;
}

.cooked-card h1 {
  margin: 0;
  padding: 0;
  font-size: 1.8rem;
}

.cooked-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  width: 100%;
  max-width: 22rem;
  margin: 1.25rem auto 0;
}

.cooked-buttons button {
  min-height: 3.25rem;
  margin: 0;
  font-size: 1.05rem;
}

/* Back and Cook, side by side at the foot of a card's back. */
.back-foot {
  display: flex;
  gap: 0.5rem;
  margin-top: auto;
  flex-shrink: 0;
}

.back-foot button {
  flex: 1;
  margin: 0;
}

/* Quick kitchen setup: two full-screen steps after the tour. */

#setup {
  position: fixed;
  inset: 0;
  z-index: 9;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: calc(4rem + env(safe-area-inset-top)) 1.25rem calc(1.25rem + env(safe-area-inset-bottom));
  overflow-y: auto;
  background: var(--bg);
  text-align: center;
}

#setup h1 {
  margin: 0;
  padding: 0;
  font-size: 1.5rem;
  line-height: 1.25;
}

.setup-tiles {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin: 0.75rem 0;
}

.setup-dishes {
  margin: 0.5rem 0;
  text-align: left;
}

.setup-dishes .category {
  align-items: center;
  padding: 0.6rem;
  text-align: center;
}

.setup-dishes .category-icon {
  font-size: 1.5rem;
}

.setup-dishes .category[aria-pressed="true"] strong {
  color: inherit;
}

#setup .primary {
  margin-top: auto;
  flex-shrink: 0;
}

/* "I've got this" beside a new ingredient on a recipe card. */
.have-this {
  min-height: 0;
  padding: 0.1rem 0.5rem;
  border-color: var(--line);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 400;
  white-space: nowrap;
}

#basket-setup {
  width: 100%;
  margin-bottom: 0.5rem;
  color: var(--accent);
}

/* The introduction: one full-screen card at a time, over everything else. */

#tour {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.75rem;
  padding: calc(2rem + env(safe-area-inset-top)) 1.5rem calc(2rem + env(safe-area-inset-bottom));
  background: var(--bg);
  text-align: center;
  touch-action: none; /* sideways swipes change card; nothing here scrolls */
  overflow: hidden;
}

/* The words, which slide with your finger as you swipe. */
.tour-slide {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: transform 0.15s ease-out;
}

#tour h1 {
  margin: 0;
  padding: 0;
  font-size: 1.6rem;
  line-height: 1.25;
}

.tour-icon {
  margin: 0;
  font-size: 4rem;
  line-height: 1.2;
}

/* The mark, where the tour opens. */
.tour-mark {
  width: 7rem;
  height: auto;
  margin: 0 auto 0.5rem;
}

/* The Tangent lockup: the mark beside the wordmark, built in HTML so the
   type stays crisp. Shown at the top of Ideas. */
.tg-lockup {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0.2rem 0 0.75rem;
  text-decoration: none;
}

.tg-wordmark {
  font-family: var(--tg-font);
  font-weight: var(--tg-weight-heavy);
  letter-spacing: var(--tg-tracking-wordmark);
  color: var(--tg-ink);
  font-size: 28px;
  line-height: 1;
}

.tg-dot {
  color: var(--tg-tangerine);
}

/* Parts of the sidebar that only exist on a wide screen. */
.wide-only {
  display: none !important;
}

/* The tab a card is about, as a small label over its title. */
.tour-tab {
  align-self: center;
  margin: 0;
  padding: 0.15rem 0.7rem;
  border: 1px solid var(--accent);
  border-radius: 1rem;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 600;
}

.tour-body {
  max-width: 26rem;
  margin: 0 auto;
  color: var(--muted);
  font-size: 1.05rem;
}

.tour-dots {
  display: flex;
  justify-content: center;
  gap: 0.4rem;
  margin: 1rem 0 0;
}

.tour-dots span {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--line);
}

.tour-dots .on {
  background: var(--chosen);
}

#tour .primary {
  width: 100%;
  max-width: 26rem;
  margin: 1rem auto 0;
}

/* Skip: a see-through button in the top corner. */
.tour-skip {
  position: absolute;
  top: calc(0.75rem + env(safe-area-inset-top));
  right: 1rem;
  background: transparent;
  color: var(--muted);
}

/* Settings */

.danger {
  color: var(--no);
  border-color: var(--no);
}

#view-settings .actions {
  margin-top: 0.5rem;
}

.hidden-items li,
#view-settings .to-buy li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.hidden-items button,
#view-settings .to-buy button {
  margin: 0;
}

#confirm .actions {
  margin-top: 1rem;
}

/* Basket */

.category-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  margin-top: 0.5rem;
}

.category {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
  padding: 0.75rem;
  border-color: var(--edge);
  border-radius: var(--tg-radius-card);
  box-shadow: var(--shadow);
  text-align: left;
}

.category[aria-pressed="true"] {
  border-color: var(--chosen);
}

/* Each mood has its own soft tint. */
.mood-any { background: var(--mood-any); }
.mood-comfort { background: var(--mood-comfort); }
.mood-quick { background: var(--mood-quick); }
.mood-light { background: var(--mood-light); }
.mood-spicy { background: var(--mood-spicy); }
.mood-protein { background: var(--mood-protein); }

#mood-tiles .category {
  border-color: transparent;
  box-shadow: none;
}

#mood-tiles .hint {
  color: var(--text);
  opacity: 0.7;
}

.category-icon {
  font-size: 1.6rem;
  line-height: 1.2;
}

.tile-never {
  text-decoration: line-through;
  color: var(--muted);
}

.hide-row {
  margin: 1rem 0 0;
}

#basket-groups h3 {
  margin: 1.25rem 0 0.5rem;
}

.add-own {
  margin-top: 1.25rem;
  padding: 0.75rem;
  border: 1px dashed var(--line);
  border-radius: 0.6rem;
}

.add-own summary {
  color: var(--accent);
  font-weight: 600;
}

.add-own input {
  width: 100%;
  min-height: 44px;
  margin-top: 0.75rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.back-link {
  min-height: 44px;
}

#view-basket .primary {
  margin-top: 1.25rem;
}

.tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Tiles arranged into rows by packTiles() in app.js. */
.tiles.packed {
  display: block;
}

.tile-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.tile-row .tile {
  white-space: nowrap;
}

/* A nearly full row is stretched so its tiles reach both edges. */
.tile-row.full .tile {
  flex: 1 1 auto;
}

.tile-weekly,
.key-weekly {
  background: var(--chosen);
  border-color: var(--chosen);
  color: var(--on-chosen);
}

.tile-staple,
.key-staple {
  background: var(--chosen-soft);
  border-color: var(--chosen);
}

.key {
  padding: 0.1rem 0.4rem;
  border: 1px solid var(--accent);
  border-radius: 0.4rem;
}

#install-guide {
  margin-top: 2rem;
}

/* Tab bar */

#tabs {
  position: fixed;
  inset: auto 0 0 0;
  display: flex;
  padding-bottom: env(safe-area-inset-bottom);
  border-top: 1px solid var(--line);
  background: var(--surface);
}

/* Each tab is a line icon over a small label. The current one takes the
   accent colour and a short bar along the top edge. */
#tabs button {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  height: var(--tabs-height);
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  color: var(--muted);
}

#tabs button::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 50%;
  width: 2rem;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: var(--chosen);
  transform: translateX(-50%) scaleX(0);
  transition: transform 0.2s ease;
}

#tabs button[aria-current="page"] {
  color: var(--text);
}

#tabs button[aria-current="page"]::before {
  transform: translateX(-50%) scaleX(1);
}

.tab-glyph {
  position: relative;
  display: flex;
}

.tab-icon {
  width: 1.4rem;
  height: 1.4rem;
}

.tab-label {
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}

#tabs button[aria-current="page"] .tab-label {
  font-weight: 700;
}

/* The number of planned meals, on the corner of the Plan icon. */
.tab-count {
  position: absolute;
  top: -0.35rem;
  right: -0.7rem;
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0 0.3rem;
  border-radius: 0.55rem;
  background: var(--chosen);
  color: var(--on-chosen);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.1rem;
  text-align: center;
}

/* --- Wide screens: a laptop or desktop --------------------------------------
   From 900px the bottom bar becomes a sidebar, the content uses more of the
   width, and grids gain columns. The phone layout above is unchanged. */

@media (hover: hover) {
  button:hover {
    border-color: var(--tg-text-muted);
  }

  .category:hover,
  .switcher button:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgb(42 26 16 / 0.08), 0 8px 20px rgb(42 26 16 / 0.09);
  }

  .primary:hover,
  .primary-inline:hover {
    border-color: var(--fill);
    filter: brightness(1.25);
  }
}

.category,
.switcher button {
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid var(--tg-tangerine);
  outline-offset: 2px;
}

@media (min-width: 900px) {
  :root {
    --sidebar: 14rem;
    --tabs-height: 0px; /* nothing along the bottom any more */
  }

  main {
    max-width: calc(var(--sidebar) + 64rem);
    margin: 0;
    padding: 2rem 2.5rem 2.5rem calc(var(--sidebar) + 2.5rem);
  }

  /* The sidebar. */
  #tabs {
    inset: 0 auto 0 0;
    width: var(--sidebar);
    flex-direction: column;
    gap: 0.25rem;
    padding: 1.5rem 0.75rem;
    border-top: 0;
    border-right: 1px solid var(--line);
  }

  .wide-only {
    display: flex !important;
  }

  #tabs .tg-lockup {
    margin: 0 0.5rem 1.5rem;
  }

  #tabs button {
    flex: 0 0 auto;
    flex-direction: row;
    justify-content: flex-start;
    gap: 0.75rem;
    height: 44px;
    padding: 0 0.75rem;
    border-radius: var(--tg-radius-button);
  }

  #tabs button::before {
    display: none;
  }

  #tabs button:hover {
    background: var(--bg);
  }

  #tabs button[aria-current="page"] {
    background: var(--chosen);
    color: var(--on-chosen);
  }

  #tabs .tab-label {
    font-size: 1rem;
  }

  #tabs .sidebar-settings {
    margin-top: auto;
  }

  /* The count of planned meals sits at the end of the row, not on the icon. */
  #tabs [data-view="plan"] .tab-count {
    position: static;
    order: 3;
    margin-left: auto;
    background: var(--fill);
    color: var(--on-fill);
  }

  #tabs [data-view="plan"] .tab-glyph {
    display: contents;
  }

  #tabs [data-view="plan"] .tab-icon {
    order: 1;
  }

  #tabs [data-view="plan"] .tab-label {
    order: 2;
  }

  /* The lockup and cog live in the sidebar now. */
  #brand-lockup,
  #open-settings {
    display: none;
  }

  h1 {
    padding-right: 0;
    font-size: 2.1rem;
  }

  /* Ideas: the moods as a 3 by 2 grid of sensible height, not the full screen. */
  #view-suggestions {
    height: calc(100dvh - 4.5rem);
  }

  #mood-tiles {
    flex: 0 0 auto;
  }

  #mood-tiles .category-grid {
    flex: 0 0 auto;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-auto-rows: 11rem;
    max-width: 56rem;
  }

  .steer-button {
    max-width: 56rem;
  }

  /* The deck keeps a readable card width. */
  #deck-pane {
    width: min(100%, 40rem);
  }

  /* Kitchen: four categories across. */
  .view.fill {
    min-height: 0;
  }

  .view.fill .category-grid {
    flex: 0 0 auto;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-auto-rows: 10rem;
  }

  #view-basket > button {
    max-width: 24rem;
  }

  /* Lists and forms keep a comfortable line length. */
  #plan-content,
  #shopping-content,
  #settings-content {
    max-width: 48rem;
  }

  .shop-foot {
    bottom: 0;
  }

  /* Recipe cards: no flipping. The summary and the ingredients and method
     are both in view, side by side in the deck. */
  .flip,
  .flipped > .flip {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 1rem;
    transform: none;
  }

  .face {
    position: relative;
    inset: auto;
    min-height: 0;
  }

  .back,
  .flipped > .flip > .back {
    transform: none;
  }

  .back,
  .flipped > .flip > .front {
    pointer-events: auto;
  }

  .front > .flip-button,
  .back-foot > .flip-button,
  .back > h2 {
    display: none;
  }

  #deck-pane {
    width: min(100%, 68rem);
  }

  /* Plan: the list on the left, the chosen recipe open on the right, its
     summary above its ingredients and method. */
  #plan-content {
    max-width: 72rem;
  }

  .plan-split {
    display: grid;
    grid-template-columns: minmax(16rem, 2fr) minmax(0, 3fr);
    gap: 2rem;
    align-items: start;
  }

  .rows .row.chosen {
    border-radius: var(--tg-radius-control);
    border-bottom-color: transparent;
    background: var(--chosen-soft);
  }

  .plan-detail {
    position: sticky;
    top: 1.5rem;
  }

  .plan-detail .list-card {
    margin-top: 0;
  }

  .plan-detail .flip {
    grid-template-columns: minmax(0, 1fr);
  }

  .list-card .front {
    min-height: 0;
  }

  .list-card .panel {
    overflow: visible;
  }

  /* Shop: the parts of the list side by side. */
  #shopping-content {
    max-width: 64rem;
  }

  .shop-columns {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 2.5rem;
    align-items: start;
  }

  /* Cook mode and the tour: a readable column in the middle. */
  #cook,
  #tour,
  #setup {
    padding-inline: max(1.25rem, calc((100vw - 44rem) / 2));
  }
}
