/* A recipe card sitting on a table.
 *
 * White card, hairline border, serif title, ruled in the green the Cooking for
 * Engineers tables used. Nothing is set in capitals and nothing is set in a
 * monospace face: this is a card you read while cooking, not a technical spec.
 */

:root {
  --ground: #e9eae7;
  --card: #ffffff;
  --ink: #17181a;
  --muted: #6c6f72;
  --hair: #dcdedb;
  --rule: #1f7a44;
  --field: #f3f8f4;
  --bad: #a8331f;
  --warn: #855609;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 8px 24px -12px rgb(0 0 0 / 22%);

  --serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #131514;
    --card: #1c1e1d;
    --ink: #e9ebe9;
    --muted: #9aa09b;
    --hair: #2e312f;
    --rule: #56b782;
    --field: #202523;
    --bad: #e08272;
    --warn: #d9ab55;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 10px 28px -14px rgb(0 0 0 / 70%);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 400 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--rule); color: #fff; }

button, input { font: inherit; }

/* ---------- top bar ---------- */

.bar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .7rem 1.25rem;
  background: var(--ground);
  border-bottom: 1px solid var(--hair);
}

.wordmark {
  margin-right: .35rem;
  font: 600 1rem/1 var(--serif);
  letter-spacing: -.01em;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}

.wordmark span { color: var(--rule); }

.bar-right { display: flex; gap: .4rem; margin-left: auto; }

.chip {
  padding: .42rem .8rem;
  font-size: .8125rem;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--hair);
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}

.chip:hover { border-color: var(--muted); }

.chip.is-on {
  color: var(--card);
  background: var(--ink);
  border-color: var(--ink);
}

.chip-count { margin-left: .4rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.chip.is-on .chip-count { color: inherit; opacity: .7; }

/* Rotation only earns a button where a card will not fit. */
.chip-narrow { display: none; }
@media (max-width: 820px) { .chip-narrow { display: inline-block; } }

/* ---------- recipes menu ---------- */

.menu { position: relative; }

.menu-panel {
  position: absolute;
  z-index: 45;
  top: calc(100% + .5rem);
  left: 0;
  width: 23rem;
  max-width: calc(100vw - 1.5rem);
  max-height: 70vh;
  overflow-y: auto;
  padding: .35rem;
  background: var(--card);
  border: 1px solid var(--hair);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.menu-panel[hidden] { display: none; }

.paste { display: block; padding: .55rem .55rem .3rem; }
.paste[hidden] { display: none; }

.paste-label {
  display: block;
  margin-bottom: .4rem;
  font-size: .75rem;
  color: var(--muted);
}

.paste-row { display: flex; gap: .4rem; }

.paste input {
  flex: 1;
  min-width: 0;
  padding: .45rem .6rem;
  font-size: .875rem;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--hair);
  border-radius: 6px;
}

.paste input:focus { outline: none; border-color: var(--rule); box-shadow: 0 0 0 2px var(--field); }

.paste button {
  padding: .45rem .9rem;
  font-size: .8125rem;
  color: var(--card);
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 6px;
  cursor: pointer;
}

.paste button:disabled { opacity: .4; cursor: default; }

.paste-status {
  margin: .5rem 0 0;
  font-size: .75rem;
  line-height: 1.5;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.paste-status:empty { margin: 0; }
.paste-status.is-good { color: var(--rule); }
.paste-status.is-warn { color: var(--warn); }
.paste-status.is-bad { color: var(--bad); }

.menu-head {
  padding: .8rem .55rem .3rem;
  font-size: .75rem;
  color: var(--muted);
}

.menu-empty { padding: .2rem .55rem .7rem; font-size: .8125rem; color: var(--muted); }

.menu-row { display: flex; border-radius: 7px; }
.menu-row:hover { background: var(--field); }

.menu-pick {
  flex: 1;
  min-width: 0;
  padding: .45rem .55rem;
  text-align: left;
  color: var(--ink);
  background: none;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
}

.menu-title {
  display: block;
  font-size: .875rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-sub {
  display: block;
  font-size: .75rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-row.is-on .menu-title { font-weight: 600; }
.menu-row.is-on .menu-title::before { content: '\2713\00a0'; color: var(--rule); }

.menu-drop {
  flex: none;
  width: 2rem;
  font-size: 1.05rem;
  line-height: 1;
  color: var(--muted);
  background: none;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
  opacity: 0;
}

.menu-row:hover .menu-drop, .menu-drop:focus-visible { opacity: 1; }
.menu-drop:hover { color: var(--bad); }

.menu-foot {
  display: block;
  width: 100%;
  margin-top: .35rem;
  padding: .6rem .55rem;
  font-size: .8125rem;
  text-align: left;
  color: var(--rule);
  background: none;
  border: 0;
  border-top: 1px solid var(--hair);
  cursor: pointer;
}

.menu-foot:hover { background: var(--field); }

/* ---------- welcome strip ---------- */

.welcome {
  max-width: 46rem;
  margin: 0 auto 1.25rem;
  padding: 1rem 1.25rem 1.1rem;
  background: var(--card);
  border: 1px solid var(--hair);
  border-radius: 8px;
}

.welcome[hidden] { display: none; }
.welcome p { margin: 0; font-size: .9375rem; line-height: 1.6; color: var(--muted); }
.welcome strong { color: var(--ink); font-weight: 600; }

.welcome-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin-top: .9rem; }

#welcome-done {
  padding: .4rem 1rem;
  font-size: .8125rem;
  color: var(--card);
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 6px;
  cursor: pointer;
}

.linky {
  padding: 0;
  font-size: .8125rem;
  color: var(--rule);
  background: none;
  border: 0;
  border-bottom: 1px solid currentColor;
  cursor: pointer;
}

/* ---------- the card ---------- */

.stage { padding: 1.5rem 1.25rem 5rem; }

/* Hug a narrow recipe, cap on a wide one and scroll inside. A short card
   should not be padded out to the width of the longest recipe. */
.card {
  width: fit-content;
  min-width: min(100%, 34rem);
  max-width: min(100%, 78rem);
  margin: 0 auto;
  padding: 1.75rem 1.75rem 1.5rem;
  background: var(--card);
  border: 1px solid var(--hair);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

/* The rule under the title spans the card, not just the text column. */
.card-head { padding-bottom: 1rem; margin-bottom: 1.25rem; border-bottom: 2px solid var(--rule); }
.card-head h1, .byline { max-width: 46rem; }

h1 {
  margin: 0;
  font: 400 1.9rem/1.15 var(--serif);
  letter-spacing: -.01em;
}

.byline { margin: .6rem 0 0; font-size: .8125rem; color: var(--muted); }
.byline a { color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
.byline a:hover { color: var(--rule); }
.byline span + span::before { content: ' · '; }
#meta:empty::before { content: none; }

.scroll { overflow-x: auto; scrollbar-width: thin; }

table.recipe { border-collapse: collapse; width: max-content; background: var(--card); }

.recipe .prelude {
  padding: .5rem .7rem;
  font-size: .8125rem;
  font-weight: 600;
  text-align: center;
  background: var(--field);
  border: 1px solid var(--rule);
}

.recipe .ing {
  min-width: 15rem;
  max-width: 22rem;
  padding: .5rem .7rem;
  font-size: .875rem;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
  vertical-align: middle;
  border: 1px solid var(--rule);
}

.recipe .op {
  min-width: 5.5rem;
  max-width: 8.5rem;
  padding: .5rem .5rem;
  text-align: center;
  vertical-align: middle;
  background: var(--field);
  border: 1px solid var(--rule);
}

.compact .recipe .op { min-width: 5rem; max-width: 7rem; }
.compact .op-detail { display: none; }

.op-label { display: block; font-size: .8125rem; font-weight: 600; line-height: 1.3; }

.op-detail {
  display: block;
  margin-top: .3rem;
  font-size: .75rem;
  line-height: 1.4;
  font-weight: 400;
  color: var(--muted);
}

.recipe .spacer { border: none; padding: 0; }
.recipe .spacer.lead { border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.recipe .spacer.close-top { border-top: 1px solid var(--rule); }
.recipe .spacer.close-bottom { border-bottom: 1px solid var(--rule); }

.rotated table.recipe { transform-origin: top left; }

.card-foot { margin-top: 1.25rem; padding-top: .9rem; border-top: 1px solid var(--hair); }
.shape { margin: 0; font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.note { margin: .5rem 0 0; font-size: .8125rem; line-height: 1.55; color: var(--muted); }
.note:empty { display: none; }

/* ---------- help sheet ---------- */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: start center;
  padding: 3rem 1.25rem;
  overflow-y: auto;
  background: rgb(0 0 0 / 42%);
}

.sheet-backdrop[hidden] { display: none; }

.sheet {
  position: relative;
  width: 100%;
  max-width: 36rem;
  padding: 2rem 2rem 1.75rem;
  background: var(--card);
  border-radius: 12px;
  box-shadow: 0 24px 60px -20px rgb(0 0 0 / 55%);
}

.sheet h2 { margin: 0 0 1.5rem; font: 400 1.5rem/1.2 var(--serif); }
.sheet h3 { margin: 0 0 .4rem; font-size: .9375rem; font-weight: 600; }
.sheet p { margin: 0; font-size: .875rem; line-height: 1.6; color: var(--muted); }
.sheet strong { color: var(--ink); font-weight: 600; }

.step + .step { margin-top: 1.6rem; padding-top: 1.6rem; border-top: 1px solid var(--hair); }

.sheet-close {
  position: absolute;
  top: .6rem;
  right: .7rem;
  width: 2rem;
  height: 2rem;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--muted);
  background: none;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}

.sheet-close:hover { color: var(--ink); background: var(--field); }

.howto { margin: .9rem 0 0; padding-left: 1.2rem; font-size: .875rem; line-height: 2; color: var(--muted); }
.howto li { padding-left: .2rem; }
.howto kbd {
  padding: .1rem .35rem;
  font: 600 .75rem/1 var(--sans);
  color: var(--ink);
  background: var(--field);
  border: 1px solid var(--hair);
  border-radius: 4px;
}

.or { margin: 0 .3rem; color: var(--muted); }

.bm {
  display: inline-block;
  padding: .22rem .7rem;
  font-size: .8125rem;
  font-weight: 600;
  color: var(--card);
  text-decoration: none;
  background: var(--rule);
  border-radius: 6px;
  cursor: grab;
}

.bm:active { cursor: grabbing; }
.copied { margin-top: .8rem; color: var(--rule); }
.copied[hidden] { display: none; }

/* ---------- narrow ---------- */

@media (max-width: 820px) {
  body { font-size: 15px; }
  .bar { padding: .6rem .8rem; gap: .5rem; }
  .wordmark { font-size: .9375rem; }
  .stage { padding: 1rem .8rem 3rem; }
  .card { padding: 1.1rem 1rem 1rem; border-radius: 8px; }
  h1 { font-size: 1.5rem; }
  .menu-panel { width: calc(100vw - 1.6rem); }
  .recipe .ing { min-width: 11rem; max-width: 15rem; }
  .sheet { padding: 1.5rem 1.2rem 1.4rem; }
}

/* ---------- print ---------- */

@media print {
  @page { size: A4 landscape; margin: 10mm; }
  body { background: #fff; color: #000; font-size: 11px; }
  .bar, .welcome, .sheet-backdrop, .card-foot { display: none; }
  .stage { padding: 0; }
  .card { max-width: none; padding: 0; border: 0; border-radius: 0; box-shadow: none; }
  h1 { font-size: 18px; }
  .recipe .ing { min-width: 0; max-width: none; font-size: 10px; padding: 3px 5px; }
  .recipe .op { min-width: 0; max-width: none; padding: 3px 4px; background: #f3f8f4; }
  .op-label { font-size: 10px; }
  .op-detail { font-size: 8px; }
  table.recipe { width: 100%; }
  .scroll { overflow: visible; }
  tr, td, th { page-break-inside: avoid; }
}

.bm-glyph { white-space: pre; }

.aside {
  margin-top: .9rem;
  padding-top: .8rem;
  border-top: 1px solid var(--hair);
  font-size: .8125rem;
  line-height: 1.6;
}

.sheet h4 {
  margin: 1.4rem 0 .35rem;
  font-size: .8125rem;
  font-weight: 600;
  color: var(--ink);
}

.howto strong { color: var(--ink); }
