/*
  Design goals
  - Dyslexia: Atkinson Hyperlegible font, large text, generous line/letter spacing,
    left-aligned, short line length, no italics, no all-caps.
  - Autism: calm muted dark palette, no animation, no images or pop-ups,
    the same layout on every page, plain literal wording.
  - ADHD: one thing at a time, tick off steps, clear "you are here" marker,
    amounts written into the steps, built-in timers.
*/
:root {
  color-scheme: dark;
  --bg: #16171b;
  --surface: #202228;
  --surface-2: #2a2d35;
  --border: #3a3e48;
  --text: #e8e3d9;        /* warm off-white: less glare than pure white */
  --muted: #a8a397;
  --amount: #f2c46d;      /* ingredient amounts */
  --amount-bg: rgba(242, 196, 109, 0.10);
  --temp: #f0a58f;        /* oven / pan temperatures */
  --timer: #86d1c3;       /* clickable times */
  --accent: #9db8f5;      /* links, focus, current step */
  --done: #6f6b63;
  --font-scale: 1;
  --letter: 0.01em;
  --word: 0.06em;
  --font: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
}
html[data-font="lexend"] { --font: "Lexend", system-ui, sans-serif; }
html[data-font="system"] { --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
html[data-spacing="wide"] { --letter: 0.05em; --word: 0.18em; }

* { box-sizing: border-box; }
html { font-size: calc(20px * var(--font-scale)); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.7;
  letter-spacing: var(--letter);
  word-spacing: var(--word);
  text-align: left;
  -webkit-text-size-adjust: 100%;
}
main { max-width: 40rem; margin: 0 auto; padding: 1.25rem 1rem 8rem; }
h1, h2, h3 { line-height: 1.3; font-weight: 700; margin: 0 0 0.5rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; margin-top: 2rem; }
h3 { font-size: 1.05rem; color: var(--muted); margin-top: 1.5rem; }
a { color: var(--accent); text-underline-offset: 0.2em; }
em, i { font-style: normal; }
p { margin: 0 0 1rem; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

button, .button, input, textarea, select { font: inherit; letter-spacing: inherit; word-spacing: inherit; }
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4em;
  min-height: 2.6rem; padding: 0.35rem 1rem;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2); color: var(--text);
  cursor: pointer; text-decoration: none;
}
button:hover, .button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: #111; border-color: var(--accent); font-weight: 700; }
input[type="url"], input[type="search"], textarea {
  width: 100%; padding: 0.6rem 0.8rem;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
}
textarea { min-height: 8rem; line-height: 1.5; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.topbar a { font-size: 0.9rem; }

/* ---------- settings ---------- */
details.settings { margin: 0 0 1.25rem; font-size: 0.9rem; }
details.settings > summary { cursor: pointer; color: var(--muted); min-height: 2.2rem; display: list-item; }
.settings-body { display: flex; flex-wrap: wrap; gap: 0.6rem 1rem; align-items: center; padding: 0.75rem 0; }
.settings-body label { display: inline-flex; align-items: center; gap: 0.4rem; }
.settings-body select { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 0.3rem 0.5rem; }
input[type="checkbox"] { width: 1.3rem; height: 1.3rem; accent-color: var(--accent); }

/* ---------- recipe list ---------- */
.recipe-list { list-style: none; padding: 0; margin: 1rem 0; display: grid; gap: 0.75rem; }
.recipe-list a {
  display: block; padding: 0.9rem 1.1rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  color: var(--text); text-decoration: none;
}
.recipe-list a:hover { border-color: var(--accent); }
.recipe-list .title { font-weight: 700; font-size: 1.1rem; display: block; }
.recipe-list .meta { color: var(--muted); font-size: 0.85rem; }

.add-box { margin-top: 2.5rem; padding: 1.25rem; background: var(--surface); border: 2px dashed var(--border); border-radius: 14px; }
.add-box h2 { margin-top: 0; }
.add-box form { display: grid; gap: 0.75rem; }
.add-box .msg { margin-top: 1rem; padding: 0.75rem 1rem; border-radius: 10px; background: var(--surface-2); }
.add-box code, pre { font-family: ui-monospace, Menlo, monospace; font-size: 0.85rem; word-spacing: normal; letter-spacing: 0; }
pre { white-space: pre-wrap; word-break: break-all; background: var(--bg); padding: 0.6rem 0.8rem; border-radius: 8px; margin: 0.5rem 0; }

/* ---------- recipe page ---------- */
.meta-line { color: var(--muted); font-size: 0.9rem; display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; margin-bottom: 1rem; }

.progress label { display: inline-flex; align-items: center; gap: 0.5rem; min-height: 2.6rem; cursor: pointer; }
.progress { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 1rem; color: var(--muted); font-size: 0.9rem; }

ol.steps { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.9rem; }
.step {
  display: grid; grid-template-columns: auto 1fr; gap: 0.9rem;
  padding: 1rem 1.1rem; background: var(--surface);
  border: 1px solid var(--border); border-left: 6px solid var(--border); border-radius: 12px;
}
.step.current { border-color: var(--accent); border-left-color: var(--accent); }
.step.done { opacity: 0.55; }
.step.done .step-text { text-decoration: line-through; text-decoration-color: var(--done); text-decoration-thickness: 2px; }
.step-check {
  width: 2.6rem; height: 2.6rem; min-height: 0; padding: 0;
  border-radius: 50%; font-weight: 700; font-size: 1rem;
}
.step.done .step-check { background: var(--done); color: var(--bg); border-color: var(--done); }
.step.current .step-check { border: 2px solid var(--accent); color: var(--accent); }
.step-text .sentence { display: block; }
.step-text .sentence + .sentence { margin-top: 0.45rem; }
.here { display: none; color: var(--accent); font-size: 0.8rem; font-weight: 700; margin-bottom: 0.2rem; }
.step.current .here { display: block; }
li.section h3 { margin: 1rem 0 0; color: var(--text); border-bottom: 1px solid var(--border); padding-bottom: 0.3rem; }

.ing { background: var(--amount-bg); border-radius: 6px; padding: 0.05em 0.3em; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.ing .amt { color: var(--amount); font-weight: 700; }
.ing .note { color: var(--muted); }
.temp { color: var(--temp); font-weight: 700; }
button.timer-chip {
  display: inline; min-height: 0; padding: 0.05em 0.45em; border-radius: 6px;
  background: transparent; color: var(--timer); border: 1px solid var(--timer); font-weight: 700;
}

/* focus mode: one step on screen */
.focus-mode li.step:not(.current), .focus-mode li.section:not(.current-section) { display: none; }
.focus-mode .step.current { font-size: 1.2rem; padding: 1.5rem; }
.focus-nav { display: none; gap: 0.75rem; margin-top: 1rem; }
.focus-mode .focus-nav { display: flex; }
.focus-nav button { flex: 1; min-height: 3.2rem; }
.all-done { padding: 1.25rem; border-radius: 12px; background: var(--surface); border: 1px solid var(--timer); }

/* shopping list */
ul.shopping { list-style: none; padding: 0; margin: 0; }
ul.shopping li.group { font-weight: 700; color: var(--muted); margin: 1.25rem 0 0.25rem; }
ul.shopping label { display: flex; gap: 0.8rem; align-items: flex-start; padding: 0.6rem 0.2rem; border-bottom: 1px solid var(--border); cursor: pointer; }
ul.shopping input { margin-top: 0.3rem; flex: none; }
ul.shopping .amt { color: var(--amount); font-weight: 700; }
ul.shopping .note { color: var(--muted); }
ul.shopping input:checked + span { opacity: 0.5; text-decoration: line-through; }
.list-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; margin: 1rem 0; }

/* timers */
.timer-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; flex-direction: column; gap: 0.4rem;
  padding: 0.6rem 1rem calc(0.6rem + env(safe-area-inset-bottom));
  background: #101114; border-top: 1px solid var(--border);
}
.timer-bar:empty { display: none; }
.timer { display: flex; align-items: center; gap: 0.6rem; max-width: 40rem; width: 100%; margin: 0 auto; }
.timer .label { flex: 1; font-size: 0.85rem; color: var(--muted); }
.timer .clock { font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--timer); letter-spacing: 0.02em; }
.timer.finished { background: #1f3a35; border-radius: 10px; padding: 0.3rem 0.6rem; }
.timer.finished .clock { color: var(--text); }
.timer button { min-height: 2.2rem; padding: 0.2rem 0.7rem; font-size: 0.85rem; }

@media (max-width: 30rem) {
  html { font-size: calc(18px * var(--font-scale)); }
  .step { gap: 0.7rem; padding: 0.9rem; }
}

/* "Highlight action words" mode: technique verbs in bold lavender, "until ..." cues underlined */
html[data-verbs="on"] .verb { color: #c9b8f7; font-weight: 700; }
html[data-verbs="on"] .cue { text-decoration: underline; text-decoration-color: #8f84b8; text-decoration-thickness: 2px; text-underline-offset: 0.25em; }

/* own recipes + media */
.own-link { margin-top: 1.75rem; padding-top: 1.25rem; border-top: 1px solid var(--border); }
.own-link p { margin-bottom: 0.75rem; }
form.own { display: grid; gap: 1.1rem; }
form.own label { display: grid; gap: 0.35rem; font-weight: 700; }
form.own .hint { font-weight: 400; color: var(--muted); font-size: 0.85rem; }
form.own input[type="text"] { width: 100%; padding: 0.6rem 0.8rem; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 10px; }
form.own textarea { min-height: 10rem; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
input[type="file"] { font-size: 0.9rem; color: var(--muted); }
input[type="file"]::file-selector-button { font: inherit; min-height: 2.6rem; padding: 0.35rem 1rem; margin-right: 0.8rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); color: var(--text); cursor: pointer; }
.media { margin: 0 0 1.5rem; }
.media > summary { cursor: pointer; font-weight: 700; min-height: 2.6rem; display: list-item; }
.media-grid { display: flex; gap: 1rem; overflow-x: auto; padding: 0.75rem 0; }
.media-item { flex: none; display: grid; gap: 0.4rem; justify-items: start; }
.media-item video, .media-item img { display: block; max-height: 70vh; max-width: min(100%, 22rem); width: auto; border-radius: 12px; background: #000; }
.media-add { display: grid; gap: 0.5rem; margin-top: 0.5rem; }
.tag { display: inline-block; font-size: 0.8rem; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 0 0.6rem; }

/* units switch */
.units { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 0.5rem 0 0.25rem; }
.units button { min-height: 2.4rem; padding: 0.25rem 0.8rem; font-size: 0.85rem; }
.units button[aria-checked="true"] { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 700; }
