/* Signpost — Squiggle Consult brand foundation.
 *
 * Client-facing, and the clients are typically 60 to 85, often recently
 * bereaved, frequently on a phone or using magnification. Every rule below that
 * looks generous (18px base, 48px targets, black body copy) is there for that
 * reason and is not a starting point to trim.
 *
 * COLOUR, and the one trap in it: #00CE3F on white measures about 1.8:1. That
 * is fine for large text, rules and graphics, and it FAILS 4.5:1 for body copy
 * by a wide margin. So green is an accent and a fill, black is the text. Where
 * green must carry text it is white-on-green at a large size, or it is a solid
 * button. There is no small green text anywhere in this app.
 */

/* Both faces are on Google Fonts. Real fallback stacks: on the day fonts.
 * gstatic is slow or blocked the page must still be readable, and a serif
 * heading falling back to Georgia looks deliberate where falling back to Times
 * looks broken. */
@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display&family=Manrope:wght@400;500;600;700&display=swap');

:root {
  /* Brand, from the official guidelines. Nothing else is a Squiggle colour. */
  --green:       #00CE3F;
  --green-tint:  #E5FAEB;   /* the green at 10%, for panels and selected states */
  --black:       #000000;
  --white:       #FFFFFF;

  /* Derived, and derived only for the jobs the brand colours cannot do:
   * a hover state, a hairline, and secondary text that still passes 4.5:1. */
  --green-deep:  #00A833;   /* hover/active on green buttons; still reads as the brand */
  --ink-soft:    #4A4A4A;   /* 9.0:1 on white — helper text, never a label */
  --rule:        #E2E2E2;
  --focus:       #0B5FFF;   /* deliberately NOT green: a focus ring has to be
                               visible ON green buttons as well as beside them */

  --font-head: 'DM Serif Display', Georgia, 'Times New Roman', serif;
  --font-body: 'Manrope', system-ui, -apple-system, 'Segoe UI', Helvetica, Arial, sans-serif;

  /* 18px minimum body text, not 16. */
  --size-body:  18px;
  --size-help:  16px;
  --size-h1:    clamp(28px, 5vw, 40px);

  /* 48px minimum touch target, double the 24px WCAG 2.2 standard. Fingers on a
   * bus, and hands that are not always steady. */
  --tap: 48px;

  --radius: 12px;
  --gap: 20px;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--size-body);
  line-height: 1.6;
  color: var(--black);
  background: var(--white);
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 {
  font-family: var(--font-head);
  font-weight: 400;          /* DM Serif Display ships one weight; asking for
                                700 gets a synthesised bold that looks wrong */
  line-height: 1.2;
  color: var(--black);
  margin: 0 0 12px;
}
h1 { font-size: var(--size-h1); }

p { margin: 0 0 16px; }

.help {                       /* the line under a heading */
  font-size: var(--size-help);
  color: var(--ink-soft);
  margin: 0 0 24px;
}

/* --- Forms ---------------------------------------------------------------
 * Every field has a real <label> above it. Never a placeholder standing in for
 * one: placeholders vanish on focus, which strands anyone who was interrupted,
 * and screen readers treat them inconsistently. */
label {
  display: block;
  font-weight: 600;
  font-size: var(--size-body);
  margin: 0 0 6px;
}

/* Every text-like input, date included. A date field left off this list keeps
   the browser's own sizing, which measured 109x21 in Chromium: a third of the
   48px floor, on a control an older client has to hit accurately. */
input[type="text"], input[type="email"], input[type="tel"], input[type="date"], select {
  width: 100%;
  min-height: var(--tap);
  padding: 12px 14px;
  font-family: inherit;
  font-size: var(--size-body);
  color: var(--black);
  background: var(--white);
  border: 2px solid #767676;   /* 4.5:1 on white: the field's own edge is a
                                  non-text contrast requirement too */
  border-radius: var(--radius);
}
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
input:focus, select:focus { border-color: var(--black); }

/* --- Buttons ------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 12px 24px;
  font-family: inherit;
  font-size: var(--size-body);
  font-weight: 700;
  text-decoration: none;
  border: 2px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
}
.btn-primary { background: var(--green); color: var(--black); }
.btn-primary:hover { background: var(--green-deep); }
.btn-secondary {
  background: var(--white);
  color: var(--black);
  border-color: var(--black);
}

/* --- The logo -----------------------------------------------------------
 * Clear space of at least the width of the "s" on every side. Never recoloured,
 * never stretched, and never replaced by the word "squiggle" set as text. */
.logo { display: block; width: 181px; height: auto; margin: 0 0 var(--gap); }
.logo-clear { padding: 18px; }

/* --- Motion -------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* --- Layout --------------------------------------------------------------- */
.sp-shell { width: 100%; max-width: 640px; margin: 0 auto; padding: 0 20px; }
.sp-header { padding: 24px 0 8px; }
.sp-main { padding-bottom: 40px; }
.sp-footer { padding: 24px 0 48px; font-size: 15px; color: var(--ink-soft); border-top: 1px solid var(--rule); margin-top: 32px; }
.sp-footer a { color: var(--black); }

/* Announce-only. Present for assistive technology, absent visually. Never
   display:none, which would remove it from the accessibility tree entirely and
   defeat the whole point. */
.sp-visually-hidden {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* A heading given focus for the screen-reader announcement must not then show a
   focus ring, because no keyboard user put it there. Everything a person can
   actually reach keeps its ring. */
h1:focus, h2:focus { outline: none; }

/* --- Choice cards --------------------------------------------------------- */
.sp-cards { display: flex; flex-direction: column; gap: 14px; margin: 0 0 24px; }

.sp-card {
  display: block; width: 100%; text-align: left;
  min-height: var(--tap);
  padding: 18px 20px;
  font-family: inherit;
  background: var(--white);
  border: 2px solid var(--rule);
  border-radius: var(--radius);
  cursor: pointer;
}
.sp-card:hover { border-color: var(--black); }
.sp-card-title { display: block; font-size: 19px; font-weight: 700; margin-bottom: 4px; }
.sp-card-body  { display: block; font-size: 16px; color: var(--ink-soft); }

/* The home visit is THE offer where one is available: bigger, tinted, green
   edged, and first in the DOM so it is also first for a screen reader and for
   the tab order. Emphasis, not pressure: the video card below it is a plain,
   full-size, perfectly ordinary button. Nothing is pre-selected. */
.sp-card-primary {
  background: var(--green-tint);
  border-color: var(--green);
  border-width: 3px;
  padding: 24px 20px;
}
.sp-card-primary .sp-card-title { font-size: 22px; }
.sp-card-primary .sp-card-body  { color: var(--black); }
.sp-card-primary:hover { border-color: var(--green-deep); }

/* --- Fields --------------------------------------------------------------- */
.sp-field { margin: 0 0 18px; }
.sp-fieldset { border: 0; padding: 0; margin: 0 0 20px; }
.sp-fieldset legend { font-weight: 600; padding: 0; margin-bottom: 8px; }

.sp-radio { display: flex; align-items: center; gap: 12px; min-height: var(--tap); }
.sp-radio input { width: 24px; height: 24px; flex: none; accent-color: var(--green); }
.sp-radio label { margin: 0; font-weight: 400; }

.sp-helper {
  margin: 0 0 20px; padding: 16px;
  background: var(--green-tint); border-radius: var(--radius);
}
.sp-helper .help { margin-bottom: 14px; }

.sp-actions { margin: 24px 0 20px; }
.sp-actions .btn { width: 100%; }

.sp-back {
  min-height: var(--tap); padding: 12px 4px;
  font: inherit; font-size: 16px;
  background: none; border: 0; color: var(--black);
  text-decoration: underline; cursor: pointer;
}

/* --- Messages ------------------------------------------------------------- */
/* Black on a tint, not red on white: this is almost always "check what you
   typed", and colour alone never carries the meaning. */
.sp-error {
  padding: 14px 16px; margin: 0 0 18px;
  background: #FFF4E5; border-left: 4px solid #B25E00;
  border-radius: 6px; font-size: 17px; color: var(--black);
}
.sp-error:focus { outline: 3px solid var(--focus); outline-offset: 2px; }

.sp-privacy, .sp-controller, .sp-phone {
  font-size: 15px; line-height: 1.5; color: var(--ink-soft); margin: 0 0 10px;
}
.sp-privacy a, .sp-phone a, .sp-controller a { color: var(--black); }
.sp-phone a { font-weight: 700; text-decoration: none; }
.sp-phone a:hover { text-decoration: underline; }

/* Who referred this client, above the question on every screen.
   Quiet on purpose: it is reassurance, not a headline, and it sits directly
   above an h1 it must not compete with. The green tint ties it to the brand
   without turning a partner's name into a banner advert for them. */
/* A CAPTION, NOT A CONTROL — and specifically not green-tinted.
   In this interface --green-tint means "the option you have chosen": it fills
   the selected card on the channel and consultant screens. Giving a static line
   the same fill borrows a meaning it has no business carrying, and on the "how
   would you like to meet?" screen it sat directly above a green-tinted selected
   card and read as part of the same group. A rule and quiet ink say "context"
   without claiming to be interactive. */
.sp-referrer {
  margin: 0 0 20px;
  padding: 0 0 12px;
  border-bottom: 1px solid var(--rule);
  color: var(--ink-soft);
  font-size: var(--size-help);
  line-height: 1.45;
}

/* --- Co-branding ----------------------------------------------------------
 * Only ever present when the partner has saved a brand kit in their portal.
 * With no kit, none of these classes are on the page and the booking form is
 * byte for byte the one it has always been. See applyCoBrand() in signpost.js.
 *
 * THE PARTNER'S COLOUR NEVER CARRIES TEXT, here or anywhere. It is whatever
 * they uploaded, and the contrast note at the top of this file applies to it
 * with more force than it does to our own green: at least we know what green
 * measures. So it gets one rule at the top of the page, beside Squiggle's
 * green, and nothing else. No button, no heading, no border a client has to
 * find. --partner-accent is set by the script and exists only on those pages.
 */
.sp-cobranded::before {
  content: '';
  display: block;
  height: 6px;
  background: linear-gradient(90deg, var(--partner-accent) 0 50%, var(--green) 50% 100%);
}

/* Wraps to two rows on a narrow phone rather than shrinking either mark. */
.sp-cobrand {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  margin: 0 0 var(--gap);
}
.sp-cobrand .logo { margin: 0; width: 150px; }

/* The join between the two marks. Decoration, and hidden from screen readers,
   but NOT drawn in the hairline colour: at 1.2:1 on white a client with the
   eyesight this site is built for sees a gap where a character should be, which
   reads as something failing to load rather than as a pairing. --ink-soft is
   the lightest grey in this file that is actually legible. */
.sp-cobrand-x {
  color: var(--ink-soft);
  font-size: 20px;
  line-height: 1;
}

/* Bounded on BOTH axes, because a partner uploads whatever their designer gave
   them: a 3000px wide wordmark, a square crest, an SVG with no intrinsic size.
   object-fit keeps every one of those inside the same 48px band without
   distorting it, and never lets a logo push Squiggle's mark off a phone. */
.sp-partner-logo {
  display: block;
  max-height: 48px;
  max-width: 190px;
  width: auto;
  height: auto;
  object-fit: contain;
}

.sp-cobrand-note {
  margin: 0 0 12px;
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink-soft);
}

/* On a phone the two marks have to share about 350px. Left alone they wrap,
   and a wrapped row leaves the "x" stranded at the end of the first line
   looking like a stray character rather than a join. Both are stepped down
   instead, which keeps the pairing readable as a pairing. Neither goes below
   the 130px the widget already uses for the Squiggle mark on an introducer's
   site. */
@media (max-width: 480px) {
  .sp-cobrand { gap: 10px; }
  .sp-cobrand .logo { width: 130px; }
  .sp-partner-logo { max-height: 40px; max-width: 130px; }
}

/* Says plainly whose form this is. In an introducer's page a client may
   reasonably think they are giving their details to the introducer. */
.sp-controller {
  padding: 10px 12px; background: var(--green-tint);
  border-radius: 8px; color: var(--black);
}

/* Honeypot. Off-screen rather than display:none, because some bots skip
   anything hidden the obvious way. A human never sees it and never fills it. */
.sp-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* --- Widget --------------------------------------------------------------- */
.sp-widget-body { background: transparent; padding: 0; }
.sp-widget {
  background: var(--white);
  border: 1px solid var(--rule);
  border-radius: 16px;
  padding: 22px 20px 20px;
  max-width: 560px;
  margin: 0 auto;
}
.sp-widget-header { margin-bottom: 4px; }
.sp-widget .logo { width: 140px; margin-bottom: 14px; }

/* BARE MODE — see the note in widget.html. Squiggle's own pages frame this
   themselves, so the widget stops drawing a card and a second logo inside one.
   The max-width and the centring stay: a booking form running the full width
   of a desktop page is worse than one that does not. */
.sp-bare .sp-widget-header { display: none; }
.sp-bare .sp-widget {
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
}
.sp-widget h1 { font-size: clamp(23px, 4.6vw, 28px); }

/* Introducer sidebars are narrow. Everything still has to work at 320px, and
   the 48px targets are the last thing to give, not the first. */
@media (max-width: 380px) {
  .sp-widget { padding: 16px 14px 14px; border-radius: 12px; }
  .sp-shell { padding: 0 14px; }
  .sp-card { padding: 15px 14px; }
  .sp-card-primary { padding: 18px 14px; }
  .sp-radio label { font-size: 17px; }
}

/* Radios and the back link were measured at 24x24 and 47x50 in a real browser,
   both under the 48px floor. The 24px radio is the WCAG 2.2 minimum and this
   app deliberately doubles it: these are the two buttons that decide whose
   details go in the client fields, tapped by someone who may be holding a phone
   in one hand. The visible control stays a sensible size; the TARGET is the
   whole row, which is what a finger actually hits. */
.sp-radio {
  gap: 14px;
  padding: 6px 4px;
  border-radius: 8px;
  cursor: pointer;
}
.sp-radio input { width: 28px; height: 28px; }
.sp-radio label {
  display: flex;
  align-items: center;
  min-height: var(--tap);
  flex: 1;
  cursor: pointer;
}
.sp-radio:hover { background: var(--green-tint); }

.sp-back { min-width: var(--tap); padding: 12px 16px; }

/* The "or choose someone else" link on the channel screen. A full-width,
   48px-tall, plainly styled control: a genuine alternative rather than a nudge,
   and never a small grey afterthought. */
.sp-choose {
  display: block; width: 100%; text-align: left;
  min-height: var(--tap);
  padding: 14px 20px;
  font: inherit; font-size: 17px;
  color: var(--black);
  background: var(--white);
  border: 2px dashed var(--rule);
  border-radius: var(--radius);
  cursor: pointer;
}
.sp-choose:hover { border-color: var(--black); border-style: solid; }

/* The one the rotation picked, marked so a client who does not care can take it
   without reading the rest. Border and a label, never colour alone. */
.sp-card-chosen { border-color: var(--green); background: var(--green-tint); }
.sp-card-chosen .sp-card-title::after {
  content: ' · suggested';
  font-size: 14px; font-weight: 500; color: var(--ink-soft);
}

.sp-choose-sub { display: block; margin-top: 4px; font-size: 15px; color: var(--ink-soft); }

/* --- Choosing a consultant ------------------------------------------------ */

/* The "got a day in mind?" panel. Both fields optional: the screen works
   untouched, so nobody is made to answer a question they have no opinion
   about. It sits above the list because a client who cares about the day
   would otherwise read five cards to discover none of them suit. */
.sp-prefer {
  background: var(--green-tint);
  border-radius: var(--radius);
  padding: 16px;
  margin: 0 0 20px;
}
.sp-prefer-title { margin: 0 0 12px; font-weight: 700; font-size: 17px; }
.sp-prefer-row { display: flex; flex-wrap: wrap; gap: 12px; }
.sp-prefer-row .sp-field { flex: 1 1 150px; margin: 0 0 12px; }
.sp-prefer-row input, .sp-prefer-row select { background: var(--white); }
.sp-prefer-go { width: auto; }
.sp-clear {
  min-height: var(--tap); padding: 12px 16px; margin-left: 8px;
  font: inherit; font-size: 16px; background: none; border: 0;
  color: var(--black); text-decoration: underline; cursor: pointer;
}

/* A person card: face, then name, then when they are next free. */
.sp-card-person { display: flex; align-items: center; gap: 14px; }
.sp-face {
  width: 56px; height: 56px; flex: none;
  border-radius: 50%; object-fit: cover;
  background: var(--green-tint);
}
.sp-person-text { display: block; min-width: 0; }

@media (max-width: 380px) {
  .sp-face { width: 48px; height: 48px; }
  .sp-prefer { padding: 12px; }
}

/* A plain note under the cards, for the case where consultants cover the area
   but are all full. Not an error: their area IS covered, and telling them
   otherwise would put them off asking again. */
.sp-note {
  margin: 4px 0 0;
  padding: 14px 16px;
  background: var(--green-tint);
  border-radius: var(--radius);
  font-size: 16px;
  color: var(--black);
}

/* The hint under the source question. Free text, so it helps to say what sort
   of answer is wanted rather than leaving an empty box to guess at. */
.sp-source-help { display: block; margin: -2px 0 8px; }
