/* PrestoHelp - a customer host. One service's help centre, or the combined
 * front door.
 *
 * --accent is NOT set here: it comes from /accent.css, which the front
 * controller writes from that service's row (Services::accent). This file
 * carries a default so the page is never unstyled if that request fails.
 *
 * Search first and visually dominant, two levels only, task-shaped titles:
 * the shape the plan takes from Shopify's help centre (PLAN.md section 4).
 * Phase 1 is the frame; topics arrive in phase 4 and search in phase 5.
 */

:root {
  --ink:      #1b1c21;
  --ink-soft: #5d6066;
  --line:     #e2e4e9;
  --page:     #ffffff;
  --card:     #f8f9fb;
  --accent:   #3f3d9e;
  --radius:   10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 17px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.wrap { max-width: 860px; margin: 0 auto; padding: 0 20px; }

.bar { border-bottom: 1px solid var(--line); }
.bar .wrap { display: flex; align-items: center; gap: 20px; min-height: 60px; }
.bar a { color: var(--ink); text-decoration: none; }
.brand { font-weight: 700; letter-spacing: -0.01em; }
.brand span { font-weight: 400; color: var(--accent); }
.away { margin-left: auto; color: var(--ink-soft); font-size: 0.9rem; }
.away:hover { text-decoration: underline; }

main { padding: 16px 0 72px; }

.hero { padding: 40px 0 28px; border-bottom: 1px solid var(--line); margin-bottom: 28px; }
.h-hero { font-size: 2.1rem; line-height: 1.15; margin: 0 0 8px; letter-spacing: -0.02em; }
.lede { font-size: 1.1rem; color: var(--ink-soft); margin: 0; }

.h-page { font-size: 1.5rem; line-height: 1.2; margin: 0 0 6px; }
.h-sec  { font-size: 1.15rem; margin: 0 0 8px; }
.h-sec.m-0 { margin: 0; }
.muted { color: var(--ink-soft); }
.m-0 { margin: 0; }

.narrow { max-width: 520px; margin: 40px auto; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.stack > * + * { margin-top: 12px; }

.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

.btn {
  display: inline-block; padding: 9px 15px; font: inherit; font-weight: 600;
  color: #fff; background: var(--accent); border: 1px solid var(--accent);
  border-radius: 7px; text-decoration: none;
}
.btn:hover { filter: brightness(0.92); }

.foot { border-top: 1px solid var(--line); padding: 20px 0; color: var(--ink-soft); font-size: 0.9rem; }
.foot p { margin: 0; }

/* ---------------------------------------------------------- phase 2 ------
 * The Ask form, a customer's own thread, and Past Questions.
 *
 * No inline styles anywhere, here or in a template: style-src is 'self' with
 * no 'unsafe-inline', so a style="..." attribute is silently ignored by the
 * browser while looking fine in the source (tests/markup.sh fails on one).
 * That is also why the Ask form's honeypot is hidden by a CLASS below.
 */

.head { margin-bottom: 20px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.9em; }
.small { font-size: 0.85rem; }
.plain { list-style: none; margin: 0; padding: 0; }
.plain li + li { margin-top: 8px; }

.note { border-radius: 7px; padding: 10px 12px; margin: 0 0 16px; border: 1px solid; }
.note-ok    { background: #eef7f3; border-color: #bfdfd2; color: #1f6f54; }
.note-error { background: #fdf0f0; border-color: #efc9ca; color: #a4262c; }

.chip {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  background: #eceef3; font-size: 0.8rem; white-space: nowrap;
}

.field label { display: block; font-weight: 600; margin-bottom: 4px; }
.field input[type="text"], .field input[type="email"], .field select, .field textarea {
  width: 100%; padding: 10px 12px; font: inherit; color: var(--ink);
  background: #fff; border: 1px solid #c3c7cf; border-radius: 7px;
}
.field textarea { resize: vertical; min-height: 120px; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
.ask .field + .field { margin-top: 12px; }

/* The honeypot (PLAN.md section 17). Off-screen rather than display:none,
 * which some robots check for. */
.away-field { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* A button that reads as a link, for a one-field POST - because a GET must
 * never act (decision 12, and section 5 rule 3). */
.link {
  background: none; border: 0; padding: 0; font: inherit; color: var(--accent);
  text-decoration: underline; cursor: pointer;
}

.talk { list-style: none; margin: 0 0 28px; padding: 0; }
.msg { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; background: var(--card); }
.msg + .msg { margin-top: 12px; }
.msg-us { background: #fff; border-left: 3px solid var(--accent); }
.msg-who { margin-bottom: 6px; }
.msg-body { white-space: normal; overflow-wrap: anywhere; }

.past li + li { margin-top: 0; }
.past-ask { margin-top: 20px; }

@media (max-width: 720px) {
  .wrap { padding: 0 16px; }
  .h-hero { font-size: 1.7rem; }
}

/* ---------------------------------------------------------- phase 4 ------
 * Browse by topic, a category, and a topic page.
 *
 * The shape is Shopify-ish and deliberately plain (PLAN.md section 4): search
 * first and visually dominant once phase 5 lands, two levels only, task-shaped
 * titles. A help page is read, so the measure is narrow and the type is large.
 *
 * No inline styles anywhere, here or in a template: style-src is self with no
 * unsafe-inline, so a style="..." attribute is ignored by the browser while
 * looking fine in the source (tests/markup.sh fails on one).
 */

.crumbs { font-size: 0.9rem; color: var(--ink-soft); margin: 18px 0 0; }
.crumbs a { color: var(--ink-soft); }
.crumb-sep { margin: 0 6px; }

.cards-browse { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.cards-browse .plain li + li { margin-top: 6px; }
.cards-browse h3 a { color: var(--ink); text-decoration: none; }
.cards-browse h3 a:hover { text-decoration: underline; }

.topiclist { list-style: none; margin: 0 0 28px; padding: 0; }
.topiclist li { padding: 14px 0; border-bottom: 1px solid var(--line); }
.topiclist li:first-child { border-top: 1px solid var(--line); }
.topiclink { font-weight: 600; font-size: 1.05rem; }

.onpage { margin: 0 0 24px; padding: 16px 18px; }
.onpage .plain li + li { margin-top: 4px; }

/* A topic body, rendered through app/Markdown.php. Only the tags that
 * allowlist can emit are styled, because only those can be here. */
.prose { max-width: 42em; }
.prose h2 { font-size: 1.3rem; margin: 32px 0 10px; letter-spacing: -0.01em; }
.prose h3 { font-size: 1.1rem; margin: 24px 0 8px; }
.prose p { margin: 0 0 14px; }
.prose ul, .prose ol { margin: 0 0 14px; padding-left: 24px; }
.prose li + li { margin-top: 6px; }
.prose code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em; background: #f1f2f6; border-radius: 4px; padding: 1px 5px;
}
.prose pre {
  background: #f1f2f6; border: 1px solid var(--line); border-radius: 7px;
  padding: 14px 16px; overflow-x: auto; margin: 0 0 16px;
}
.prose pre code { background: none; padding: 0; }
.prose blockquote {
  margin: 0 0 16px; padding: 2px 0 2px 16px;
  border-left: 3px solid var(--line); color: var(--ink-soft);
}
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 28px 0; }
.prose a { color: var(--accent); }

.topic header.head { margin-bottom: 24px; }
.foot-ask { margin-top: 36px; }
.foot-ask .inlineform { display: flex; gap: 8px; align-items: center; }
.btn-small { padding: 6px 12px; font-size: 0.9rem; }

@media (max-width: 720px) {
  .prose h2 { font-size: 1.2rem; }
}

/* ========================================================= phase 5: search */
/* The box is in the header on every page of the zone, because the reader who
   needs it most is the one halfway down a topic that is not the answer. */
.findbar { position: relative; margin-left: auto; display: flex; gap: 8px; }
.findbar input[type="search"] {
  font: inherit; padding: 7px 11px; width: 220px;
  border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--ink);
}
.findbar input[type="search"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.findbar button {
  font: inherit; font-weight: 600; padding: 7px 13px; cursor: pointer;
  color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 7px;
}
.findbar button:hover { border-color: var(--ink-soft); }
/* The search box has taken the auto margin that used to push this right. */
.away { margin-left: 0; }

/* The suggestions. Hidden until the script has something to put in it, and
   absolutely positioned so the header does not move as it fills. */
.suggest {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 20;
  list-style: none; margin: 0; padding: 4px;
  background: var(--card); border: 1px solid var(--line); border-radius: 7px;
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.08);
}
.suggest li + li { margin-top: 2px; }
.suggest a {
  display: block; padding: 7px 9px; border-radius: 5px;
  font-size: 0.95rem; color: var(--ink); text-decoration: none;
}
.suggest a:hover, .suggest a:focus-visible { background: var(--page); outline: none; }

/* THE ASK FORM'S THREE SUGGESTIONS SIT IN THE FLOW, not over it (PLAN.md
   section 5, phase 7). The search box's list is absolute so that the header
   does not move as it fills; here the opposite is wanted - a list floating
   over the form would cover the question somebody is in the middle of writing,
   and the nearest positioned ancestor is the page rather than the field, so it
   would land somewhere nobody chose. Each row is a title and its button, which
   is why this one is a flex row where the box's is a stack of links. */
.suggest-ask { position: static; margin-top: 10px; padding: 6px; }
.suggest-ask li { display: flex; align-items: center; gap: 10px; }
.suggest-ask li + li { margin-top: 4px; }
.suggest-ask a { flex: 1 1 auto; }
.suggest-ask .btn { flex: 0 0 auto; }

/* The thank-you that takes the form's place when a suggestion answered it. */
.ask-answered { margin-top: 18px; }

/* A RESULT IS A SENTENCE FROM THE ANSWER, so it is given room to be read: the
   title, the heading it was found under, and the sentence itself. */
.results { list-style: none; margin: 0 0 28px; padding: 0; }
.result { padding: 18px 0; border-bottom: 1px solid var(--line); }
.result:first-child { padding-top: 4px; }
.result h2 a { color: var(--accent); text-decoration: none; }
.result h2 a:hover { text-decoration: underline; }
.result-where { font-size: 0.9rem; font-weight: 600; color: var(--ink-soft); }

.pages { display: flex; gap: 6px; margin: 0 0 24px; }
.pages a, .pages .here {
  min-width: 34px; text-align: center; padding: 5px 8px;
  border: 1px solid var(--line); border-radius: 6px; text-decoration: none; color: var(--ink);
}
.pages .here { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

/* The label and the hint on the search box: read aloud, never drawn. */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

@media (max-width: 720px) {
  /* The box drops to its own line rather than squeezing the brand out. */
  .bar .wrap { flex-wrap: wrap; padding-bottom: 12px; }
  .findbar { order: 3; width: 100%; margin-left: 0; }
  .findbar input[type="search"] { width: auto; flex: 1; }
}
