/* recipes4humans: plain text on a plain background. No images, no animation. */

:root {
  --bg: #fff;
  --text: #111;
  --muted: #555;
  --border: #bbb;
  --link: #0645ad;
  --accent: #111;
  --on-accent: #fff;
  --flag: #8a4b00;
  --touch: 44px;
  --numw: 2.6ch; /* width of a step number column: room for "10." */
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121212;
    --text: #e8e8e8;
    --muted: #a0a0a0;
    --border: #444;
    --link: #8ab4f8;
    --accent: #e8e8e8;
    --on-accent: #121212;
    --flag: #f0b060;
  }
}

:root[data-theme="dark"] {
  --bg: #121212;
  --text: #e8e8e8;
  --muted: #a0a0a0;
  --border: #444;
  --link: #8ab4f8;
  --accent: #e8e8e8;
  --on-accent: #121212;
  --flag: #f0b060;
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 19px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  overflow-wrap: anywhere;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

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

.bar, #app, #hint { max-width: 40rem; margin: 0 auto; padding-left: 16px; padding-right: 16px; }

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--touch);
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}
.bar a { display: inline-flex; align-items: center; min-height: var(--touch); color: var(--text); }
.bar .brand { font-weight: 700; text-decoration: none; }

#app { padding-top: 8px; padding-bottom: 48px; }

h1 { font-size: 1.5rem; line-height: 1.25; margin: 1rem 0 .5rem; }
h2 { font-size: 1.2rem; margin: 1.75rem 0 .25rem; padding-bottom: .15rem; border-bottom: 1px solid var(--border); }
h3 { font-size: 1rem; margin: 0 0 .25rem; color: var(--muted); font-weight: 600; }

p { margin: .5rem 0; }
.lede { color: var(--muted); margin-top: 0; }
.note, .source { color: var(--muted); font-size: .85rem; }
.message { color: var(--flag); min-height: 1.6em; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* Form controls */
textarea, input[type="url"] {
  display: block;
  width: 100%;
  font: inherit;
  font-size: 16px; /* 16px stops iOS from zooming on focus */
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 10px;
  margin: .5rem 0;
}
textarea { min-height: 12rem; resize: vertical; }
input:disabled { opacity: .6; }
label { display: block; margin-top: .75rem; }

button, .button {
  font: inherit;
  font-size: 1rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--text);
  border-radius: 0;
  min-height: var(--touch);
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin: 0;
  text-decoration: none;
}
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); color: var(--on-accent); font-weight: 600; }
button.link { border: 0; color: var(--link); text-decoration: underline; padding: 0 4px; }
:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; }

.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin: .75rem 0; }

.link-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: stretch; margin-top: .5rem; }
.link-row input { flex: 1 1 14rem; margin: 0; min-height: var(--touch); }
.link-row button { flex: 0 0 auto; }
.link-form .message { margin: .25rem 0 0; min-height: 0; }
.link-form .message:empty { display: none; }

/* The "paste the text" option */
details.text-option { margin: .5rem 0 0; }
details.text-option summary {
  display: flex;
  align-items: center;
  min-height: 36px;
  font-size: .75rem;
  color: var(--muted);
  text-decoration: underline;
  cursor: pointer;
}
details.text-option[open] summary { margin-bottom: .25rem; }

/* What it fixes */
ul.fixes { list-style: none; margin: .5rem 0 0; padding: 0; }
.fixes li { padding: .6rem 0; border-bottom: 1px solid var(--border); }
.fixes li:last-child { border-bottom: 0; }
.fixes s { display: block; color: var(--muted); }
.fixes .after { display: block; font-weight: 600; }
ol.after-lines { list-style: none; margin: .1rem 0 0 1.1rem; padding: 0 0 0 .75rem; border-left: 3px solid var(--border); font-weight: 600; }
.after-lines .mark { display: inline-block; min-width: 2.6ch; margin-right: .4rem; color: var(--muted); font-weight: 400; }

/* Before and after */
.example { display: grid; grid-template-columns: 1fr; gap: 12px; }
pre {
  margin: 0;
  padding: 10px;
  font: inherit;
  font-size: .9rem;
  line-height: 1.5;
  white-space: pre-wrap;
  border: 1px solid var(--border);
}

/* Cooking view */
ul.lines, ol.lines, .meanwhile ul { list-style: none; margin: 0; padding: 0; }

/* A line is a row: the tick-off area, then its small "original" / "flag" buttons at the end.
   Opened panels and Meanwhile blocks wrap underneath at full width. */
.line { display: flex; flex-wrap: wrap; align-items: flex-start; border-bottom: 1px solid var(--border); padding: 2px 0 0; }
.line > .check { flex: 1 1 0; width: auto; }
.line > .panel, .line > .meanwhile { flex: 0 0 100%; box-sizing: border-box; max-width: 100%; }
.line:last-child { border-bottom: 0; }

.check {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: .55rem 0;
  min-height: var(--touch);
}
.check .num { min-width: var(--numw); flex: none; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.check .body { display: block; flex: 1; min-width: 0; }
.check .text { display: block; }
.check .note { display: block; font-size: .8rem; line-height: 1.4; color: var(--muted); margin-top: .15rem; }
.gather .check { padding-left: 0; }

.line.done .text, .line.done .num { text-decoration: line-through; }
.line.done .check { opacity: .5; }

/* Stacked, not side by side, so a line with both buttons doesn't lose more text width. */
.tools { display: flex; flex-direction: column; align-items: flex-end; flex: none; gap: 0; margin: 0; padding: 0; }
button.mini {
  border: 0;
  background: transparent;
  color: var(--link);
  text-decoration: underline;
  font-size: .8rem;
  padding: 0 0 0 10px;
  min-width: var(--touch);
  justify-content: flex-end;
}
button.mini[aria-expanded="true"] { font-weight: 700; }

.panel { margin: 0 0 .5rem calc(var(--numw) + .6rem); padding: 6px 10px; border-left: 3px solid var(--border); font-size: .9rem; line-height: 1.45; }
.gather .panel { margin-left: 0; }
.panel p { margin: .25rem 0; }
.flag-panel { border-left-color: var(--flag); }
.orig-label { display: block; color: var(--muted); font-size: .75rem; }

.meanwhile { margin: 0 0 .5rem calc(var(--numw) + .6rem); padding-left: 12px; border-left: 3px solid var(--border); }
.meanwhile .label { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-top: .35rem; }
.meanwhile .line { border-bottom: 0; }
.meanwhile .panel { margin-left: 0; }

.note-block { font-size: .9rem; color: var(--muted); }

/* Library */
ul.library { list-style: none; margin: 0; padding: 0; }
.library li { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--border); }
.library .rtitle { flex: 1; min-width: 0; display: block; padding: 10px 0; color: var(--text); text-decoration: none; min-height: var(--touch); }
.library .rtitle span { display: block; }
.library .date { color: var(--muted); font-size: .8rem; }
.library button.mini { min-height: var(--touch); padding: 0 8px; }
.choices { display: flex; flex-wrap: wrap; gap: 0 20px; }
.choice { display: inline-flex; align-items: center; gap: 6px; min-height: var(--touch); margin: 0; }
.choice input { width: 20px; height: 20px; margin: 0; }

/* iPhone home-screen hint */
#hint:empty { display: none; }
#hint .hint { border: 1px solid var(--border); padding: 4px 12px 4px; margin: 0 0 24px; font-size: .9rem; line-height: 1.45; }

@media (min-width: 560px) {
  .example { grid-template-columns: 1fr 1fr; }
}

/* Collapsible sections and steps. Big tap targets: you're cooking, with one hand. */
.sechead { margin: 1.25rem 0 .25rem; padding: 0; border-bottom: 1px solid var(--border); }
.chead { display: flex; align-items: center; gap: .6rem; width: 100%; min-height: 52px; border: 0; background: transparent; text-align: left; font: inherit; font-weight: 700; padding: 0; }
.chead .title { flex: 1; }
.count { font-size: .9rem; font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }
.sec.alldone .count::after { content: ' \2713'; }
.chev { flex: none; width: 0; height: 0; margin: 0 .2rem; border-left: 6px solid transparent; border-right: 6px solid transparent; border-top: 8px solid var(--muted); transition: transform .12s; }
.collapsed > .sechead .chev, .group.collapsed .chev { transform: rotate(-90deg); }
.sec.collapsed > .cbody { display: none; }

.group { grid-template-areas: "toggle summary" "toggle list"; }
.gtoggle { grid-area: toggle; display: flex; align-items: flex-start; justify-content: flex-end; gap: .35rem; border: 0; background: transparent; padding: 0; min-height: var(--touch); font: inherit; }
.gtoggle .chev { margin-top: .85rem; }
.gtoggle .gnum { padding-top: .55rem; }
.gsummary { grid-area: summary; display: none; text-align: left; border: 0; background: transparent; padding: .55rem 0; min-height: var(--touch); font: inherit; min-width: 0; }
.gsummary .gmore { color: var(--muted); font-size: .85rem; }
.group > ol.lines.sub { grid-area: list; }
.group.collapsed > .gsummary { display: block; }
.group.collapsed > ol.lines.sub { display: none; }
.group.alldone > .gsummary .gfirst { text-decoration: line-through; }
.group.alldone > .gsummary { opacity: .5; }

/* A recipe paragraph that gave several actions: its number on the left, the actions indented (a, b, c) */
.group { display: grid; grid-template-columns: var(--numw) 1fr; column-gap: .6rem; border-bottom: 1px solid var(--border); padding-top: 2px; }
.group:last-child { border-bottom: 0; }
.gnum { white-space: nowrap; text-align: right; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; padding-top: .55rem; }
ol.lines.sub { border-left: 3px solid var(--border); padding-left: 10px; min-width: 0; }
.sub > .line { border-bottom: 1px dotted var(--border); }
.sub > .line:last-child { border-bottom: 0; }

/* Print: one dense page where it can. Plain black on white, no controls, Gather in two columns. */
@media print {
  @page { margin: .5in; }
  :root, :root[data-theme="dark"] { --bg: #fff; --text: #000; --muted: #333; --border: #999; --link: #000; color-scheme: light; }
  html, body { background: #fff; color: #000; }
  body { font-size: 10pt; line-height: 1.25; }
  .bar, #hint, .row, .tools, .panel, .note-block, .chev, .count, .gsummary { display: none !important; }
  .sec.collapsed > .cbody, .group.collapsed > ol.lines.sub { display: block !important; }
  .sechead { margin: 0; border: 0; }
  .chead { min-height: 0; font: inherit; }
  .gtoggle { min-height: 0; }
  .gtoggle .gnum { padding-top: 1pt; }
  #app { max-width: none; padding: 0; }
  h1 { font-size: 15pt; line-height: 1.15; margin: 0 0 2pt; }
  h2 { font-size: 8.5pt; text-transform: uppercase; letter-spacing: .06em; border-bottom: 1px solid #000; margin: 7pt 0 2pt; padding-bottom: 1pt; }
  .source { font-size: 8pt; margin: 0 0 2pt; }
  .source a { color: #000; text-decoration: none; }
  ul.gather-list { column-count: 2; column-gap: 18pt; }
  .line { border-bottom: 0; padding: 0; break-inside: avoid; }
  .check { padding: 1pt 0; min-height: 0; gap: 5pt; font: inherit; color: inherit; }
  .check .num { min-width: var(--numw); color: #000; }
  .check .note { font-size: 8pt; margin-top: 0; color: #333; }
  .line.done .text, .line.done .num { text-decoration: none; }
  .line.done .check { opacity: 1; }
  .group { grid-template-columns: var(--numw) 1fr; column-gap: 5pt; border-bottom: 0; padding-top: 0; break-inside: avoid; }
  .gnum { padding-top: 1pt; color: #000; }
  ol.lines.sub { border-left: 1px solid #777; padding-left: 6pt; }
  .sub > .line { border-bottom: 0; }
  .meanwhile { margin: 0 0 1pt var(--numw); padding-left: 6pt; border-left: 1px dotted #777; }
  .meanwhile .label { font-size: 7.5pt; margin-top: 0; color: #333; }
}
