/* MediWatch "Thread": the medicine locator (pharmacies to call + the
 * zero-result "What to do now" option stack). Loads after thread.css.
 * Brand record: docs/brand/BRAND.md
 *
 * Two roots, both safe on legacy pages (Webflow CSS sets h2 to 84px, html to
 * 62.5%, a to underline; page CSS sets ".content p", ".content h2"...). Every
 * rule here is scoped two classes deep, so it outranks those, and pins the
 * properties they touch ("chrome isolation", as thread.css does for the header).
 *
 * 1. The form shell, written by the emitters (server.js medicineEngagementModule,
 *    seo/generate-all-pages.js A-Z hub, scripts/generate-demand-capture-pages.js).
 *    Keep the data-* hooks: public/assets/js/medicine-locator.js binds the FIRST
 *    [data-medicine-locator-form], [data-medicine-locator-status] and
 *    [data-medicine-locator-results] on the page.
 *
 *    .th-loc          wrapper around everything below (required: the other shell
 *                     classes are scoped to it)
 *    .th-loc-title    optional heading;  .th-loc-lede  optional intro paragraph
 *    .th-loc-form     the <form data-medicine-locator-form>; wraps to one column
 *                     at 760px and below
 *    .th-loc-field    a field wrapper (<label> + <input>), or the <input> itself.
 *                     Inputs are 54px tall at 16.5px, so iOS never zooms.
 *    .th-loc-submit   the submit button (teal, 54px; full width on phones). Its
 *                     own label is kept and restored after "Checking..."
 *    .th-loc-status   the [data-medicine-locator-status] line (role="status");
 *                     data-state="error" turns it into an error line
 *    .th-loc-results  the [data-medicine-locator-results] container
 *    .th-loc-note     optional fine print; .th-loc-callout optional calm callout
 *
 *    <section class="th-loc" aria-labelledby="loc-title">
 *      <h2 class="th-loc-title" id="loc-title">Nearby pharmacies to call about Ramipril</h2>
 *      <form class="th-loc-form" data-medicine-locator-form action="/api/medicine-locator/search" method="post" novalidate>
 *        <input type="hidden" name="medicine" value="Ramipril">
 *        <div class="th-loc-field">
 *          <label for="loc-pc">Your postcode</label>
 *          <input id="loc-pc" name="postcode" type="text" autocomplete="postal-code" autocapitalize="characters"
 *                 autocorrect="off" spellcheck="false" enterkeyhint="search" placeholder="e.g. M1 1AE" required>
 *        </div>
 *        <button class="th-loc-submit" type="submit">Show pharmacies to call</button>
 *      </form>
 *      <p class="th-loc-status" data-medicine-locator-status role="status" aria-live="polite">Stock is not confirmed.</p>
 *      <div class="th-loc-results" data-medicine-locator-results></div>
 *    </section>
 *
 *    A visible medicine field is one more .th-loc-field (name="medicine",
 *    autocomplete="off", enterkeyhint="next"). Never put the medicine in a URL.
 *
 * 2. The output, written by medicine-locator.js inside the results container:
 *    .th-loc-out and its .th-loc-* children. No inline styles.
 *
 * medicine-locator.js also adds this stylesheet itself (same ?v= as thread.css)
 * when a page has not linked it, so the output is styled everywhere.
 */

/* ── shared isolation ───────────────────────────────────────── */
.th-loc, .th-loc-out {
  font-family: var(--th-font); font-style: normal; font-weight: 400; font-size: 16px; line-height: 1.55;
  color: var(--th-ink-700); letter-spacing: normal; text-transform: none; text-align: left;
  word-break: normal; overflow-wrap: break-word;
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
}
.th-loc *, .th-loc *::before, .th-loc *::after,
.th-loc-out *, .th-loc-out *::before, .th-loc-out *::after { box-sizing: border-box; }
.th-loc svg, .th-loc-out svg { display: inline-block; flex: none; max-width: none; overflow: visible; vertical-align: middle; }
.th-loc :focus-visible, .th-loc-out :focus-visible { outline: 3px solid var(--th-teal-700); outline-offset: 3px; }

/* ── 1. form shell ──────────────────────────────────────────── */
.th-loc .th-loc-title {
  margin: 0 0 6px; padding: 0; border: 0;
  font: 680 20px/1.25 var(--th-font); letter-spacing: -.02em; color: var(--th-ink-900); text-transform: none;
}
.th-loc .th-loc-lede { margin: 0 0 4px; padding: 0; font-size: 15.5px; line-height: 1.55; color: var(--th-ink-700); }
.th-loc .th-loc-form {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px;
  margin: 12px 0 0; padding: 0; border: 0; background: none; box-shadow: none;
}
.th-loc .th-loc-field { flex: 1 1 200px; min-width: 0; margin: 0; padding: 0; }
.th-loc .th-loc-field label {
  display: block; margin: 0 0 8px; padding: 0;
  font: 650 14.5px/1.3 var(--th-font); color: var(--th-ink-900); letter-spacing: normal; text-transform: none;
}
.th-loc .th-loc-field input, .th-loc input.th-loc-field {
  display: block; width: 100%; height: 54px; margin: 0; padding: 0 16px; border: 0; border-radius: 13px; outline: 0;
  background: #fff; box-shadow: inset 0 0 0 1.5px var(--th-field);
  font: 520 16.5px/1.2 var(--th-font); color: var(--th-ink-900); letter-spacing: .01em;
  -webkit-appearance: none; appearance: none; touch-action: manipulation; transition: box-shadow .2s;
}
.th-loc .th-loc-field input::placeholder, .th-loc input.th-loc-field::placeholder { color: var(--th-ink-500); opacity: 1; }
.th-loc .th-loc-field input:focus, .th-loc input.th-loc-field:focus {
  outline: 0; box-shadow: inset 0 0 0 1.5px var(--th-teal-700), 0 0 0 5px rgba(25, 195, 177, .18);
}
.th-loc .th-loc-field input[aria-invalid="true"], .th-loc input.th-loc-field[aria-invalid="true"] { box-shadow: inset 0 0 0 1.5px var(--th-short-ink); }
.th-loc .th-loc-submit {
  flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 54px; min-width: 44px; margin: 0; padding: 0 22px; border: 0; border-radius: 13px;
  background: var(--th-teal-700); color: #fff; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), 0 8px 18px -10px rgba(10, 116, 104, .75);
  font: 650 16px/1 var(--th-font); letter-spacing: -.005em; text-transform: none; text-decoration: none; white-space: nowrap;
  cursor: pointer; touch-action: manipulation; transition: background-color var(--th-dur-fast), transform var(--th-dur-fast) var(--th-ease-out);
}
@media (hover: hover) { .th-loc .th-loc-submit:hover { background: var(--th-teal-800); } }
.th-loc .th-loc-submit:active { transform: scale(.975); }
.th-loc .th-loc-submit[disabled] { opacity: .72; cursor: progress; transform: none; }
.th-loc .th-loc-status { margin: 12px 0 0; padding: 0; font: 500 15px/1.5 var(--th-font); color: var(--th-ink-500); }
.th-loc .th-loc-status[data-state="error"] { color: var(--th-short-ink); font-weight: 600; }
.th-loc .th-loc-results { margin: 14px 0 0; padding: 0; scroll-margin-top: calc(var(--th-header-h, 64px) + 12px); }
.th-loc .th-loc-results:empty { margin: 0; }
.th-loc .th-loc-note { margin: 10px 0 0; padding: 0; font-size: 13.5px; line-height: 1.5; color: var(--th-ink-500); }
.th-loc .th-loc-callout {
  margin: 14px 0 0; padding: 12px 14px; border-radius: 12px; background: var(--th-wash);
  box-shadow: inset 0 0 0 1px var(--th-line); font-size: 15px; line-height: 1.55; color: var(--th-ink-700);
}
.th-loc .th-loc-callout strong { color: var(--th-ink-900); font-weight: 680; }

/* ── 2. output ──────────────────────────────────────────────── */
.th-loc-out { display: block; margin: 0; padding: 0; }
.th-loc-out strong, .th-loc-out b { font-weight: 680; color: var(--th-ink-900); }

/* zero results: "What to do now" */
.th-loc-out .th-loc-h {
  margin: 4px 0 6px; padding: 0; border: 0;
  font: 700 22px/1.2 var(--th-font); letter-spacing: -.022em; color: var(--th-ink-900); text-transform: none;
}
.th-loc-out .th-loc-lede { margin: 0 0 14px; padding: 0; font-size: 15.5px; line-height: 1.6; color: var(--th-ink-700); }
.th-loc-out .th-loc-steps { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.th-loc-out .th-loc-step {
  position: relative; margin: 0; padding: 18px 20px; border-radius: 18px; list-style: none;
  background: #fff; box-shadow: inset 0 0 0 1px var(--th-line), var(--th-shadow-sm);
  font-size: 15.5px; line-height: 1.6; color: var(--th-ink-700);
}
.th-loc-out .th-loc-step::before, .th-loc-out .th-loc-ph::before, .th-loc-out .th-loc-res::before { content: none; display: none; }
.th-loc-out .th-loc-step::marker, .th-loc-out .th-loc-ph::marker, .th-loc-out .th-loc-res::marker { content: none; }
/* The nearby-pharmacies card is the key object: it gets the answer card's spine. */
.th-loc-out .th-loc-step-key::after {
  content: ""; position: absolute; left: 0; top: 18px; bottom: 18px; width: 3px; border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, var(--th-turq-500), var(--th-green-500));
}
.th-loc-out .th-loc-step-h {
  display: flex; align-items: flex-start; gap: 12px; margin: 0 0 8px; padding: 0; border: 0;
  font: 680 18px/1.3 var(--th-font); letter-spacing: -.015em; color: var(--th-ink-900); text-transform: none;
}
.th-loc-out .th-loc-n {
  display: inline-grid; place-items: center; flex: none; width: 28px; height: 28px; margin-top: -2px; border-radius: 50%;
  background: var(--th-teal-700); color: #fff; font: 750 14px/1 var(--th-font); font-variant-numeric: tabular-nums;
}
.th-loc-out .th-loc-p { margin: 0; padding: 0; font-size: 15.5px; line-height: 1.6; color: var(--th-ink-700); }
.th-loc-out .th-loc-p + .th-loc-p { margin-top: 10px; }
.th-loc-out .th-loc-go { margin: 6px 0 0; padding: 0; font-size: 15.5px; line-height: 1.5; color: var(--th-ink-700); }
.th-loc-out .th-loc-link {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0;
  font: 650 15.5px/1.3 var(--th-font); color: var(--th-teal-700); letter-spacing: normal;
  text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 3px; touch-action: manipulation;
}
.th-loc-out .th-loc-link svg { width: 18px; height: 18px; transition: transform .25s var(--th-ease-out); }
@media (hover: hover) {
  .th-loc-out .th-loc-link:hover { color: var(--th-teal-800); }
  .th-loc-out .th-loc-link:hover svg { transform: translateX(3px); }
}
.th-loc-out .th-loc-script {
  margin: 12px 0 0; padding: 12px 14px; border-radius: 12px; background: var(--th-mint);
  font-size: 15px; line-height: 1.55; color: var(--th-ink-900);
}
.th-loc-out .th-loc-script strong { color: var(--th-teal-800); }
.th-loc-out .th-loc-warn {
  display: flex; align-items: flex-start; gap: 10px; margin: 14px 0 0; padding: 12px 14px; border-radius: 12px;
  background: var(--th-wash); box-shadow: inset 0 0 0 1.5px var(--th-line-strong);
  font-size: 15px; line-height: 1.55; color: var(--th-ink-700);
}
.th-loc-out .th-loc-warn svg { width: 20px; height: 20px; margin-top: 2px; color: var(--th-teal-700); }

/* pharmacies to call (the homepage's .th-ph pattern) */
.th-loc-out .th-loc-ph-list { display: grid; gap: 8px; margin: 12px 0 0; padding: 0; list-style: none; }
.th-loc-out .th-loc-ph {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 14px; align-items: center;
  margin: 0; padding: 12px 12px 12px 16px; border-radius: 14px; list-style: none;
  background: #fff; box-shadow: inset 0 0 0 1px var(--th-line);
}
.th-loc-out .th-loc-ph[hidden] { display: none; }
.th-loc-out .th-loc-ph-name { grid-column: 1; font: 700 16px/1.35 var(--th-font); color: var(--th-ink-900); overflow-wrap: anywhere; }
.th-loc-out .th-loc-ph-addr { grid-column: 1; font-size: 14px; line-height: 1.45; color: var(--th-ink-500); overflow-wrap: anywhere; }
.th-loc-out .th-loc-ph-miles { color: var(--th-teal-700); font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.th-loc-out .th-loc-call {
  grid-column: 2; grid-row: 1 / span 2;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; min-width: 44px; margin: 0; padding: 0 14px; border-radius: 12px;
  background: var(--th-mint); color: var(--th-teal-800);
  font: 650 15px/1 var(--th-font); font-variant-numeric: tabular-nums; letter-spacing: normal;
  text-decoration: none; white-space: nowrap; touch-action: manipulation;
  transition: background-color .2s, color .2s;
}
.th-loc-out .th-loc-call svg { width: 17px; height: 17px; transition: transform .3s var(--th-ease-spring); }
@media (hover: hover) {
  .th-loc-out .th-loc-call:hover { background: var(--th-teal-700); color: #fff; }
  .th-loc-out .th-loc-call:hover svg { transform: rotate(-14deg) scale(1.1); }
}
.th-loc-out .th-loc-more {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; margin: 4px 0 0; padding: 0 2px;
  border: 0; border-radius: 8px; background: none; box-shadow: none; cursor: pointer;
  font: 650 15.5px/1.2 var(--th-font); color: var(--th-teal-700); text-transform: none; letter-spacing: normal;
  text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 3px; touch-action: manipulation;
}
.th-loc-out .th-loc-attrib { margin: 10px 0 0; padding: 0; font-size: 13px; line-height: 1.5; color: var(--th-ink-500); }

/* small print */
.th-loc-out .th-loc-byline { margin: 14px 0 0; padding: 0; font-size: 13.5px; line-height: 1.55; color: var(--th-ink-500); }
.th-loc-out .th-loc-byline a { color: var(--th-ink-700); text-decoration: underline; text-underline-offset: 3px; }
.th-loc-out .th-loc-safety {
  margin: 12px 0 0; padding: 12px 14px; border-radius: 12px; background: var(--th-wash);
  font-size: 14.5px; line-height: 1.55; color: var(--th-ink-700);
}
.th-loc-out .th-loc-safety + .th-loc-safety { margin-top: 8px; }

/* reported availability (results[] not empty) */
.th-loc-out .th-loc-res-list { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.th-loc-out .th-loc-res {
  margin: 0; padding: 16px 18px; border-radius: 18px; list-style: none;
  background: #fff; box-shadow: inset 0 0 0 1px var(--th-line), var(--th-shadow-sm);
}
.th-loc-out .th-loc-res-name {
  margin: 0; padding: 0; border: 0;
  font: 700 17px/1.3 var(--th-font); letter-spacing: -.01em; color: var(--th-ink-900); text-transform: none; overflow-wrap: anywhere;
}
.th-loc-out .th-loc-res-addr { margin: 2px 0 0; padding: 0; font-size: 14px; line-height: 1.45; color: var(--th-ink-500); overflow-wrap: anywhere; }
.th-loc-out .th-loc-pills { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; padding: 0; }
.th-loc-out .th-loc-pill {
  display: inline-flex; align-items: center; gap: 7px; min-height: 26px; padding: 3px 11px; border-radius: 999px;
  background: var(--th-wash); box-shadow: inset 0 0 0 1px var(--th-line-strong);
  font: 650 13px/1.2 var(--th-font); color: var(--th-ink-700); font-variant-numeric: tabular-nums;
}
/* availability: a word plus a dot whose shape differs, never colour alone */
.th-loc-out .th-loc-pill.is-confirmed, .th-loc-out .th-loc-pill.is-unconfirmed { padding-left: 9px; }
.th-loc-out .th-loc-pill.is-confirmed::before, .th-loc-out .th-loc-pill.is-unconfirmed::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%; flex: none; box-sizing: border-box;
}
.th-loc-out .th-loc-pill.is-confirmed { color: var(--th-maybe-ink); background: var(--th-maybe-bg); box-shadow: inset 0 0 0 1px var(--th-maybe-line); }
.th-loc-out .th-loc-pill.is-confirmed::before { background: var(--th-maybe-dot); }
.th-loc-out .th-loc-pill.is-unconfirmed { color: var(--th-limited-ink); background: var(--th-limited-bg); box-shadow: inset 0 0 0 1px var(--th-limited-line); }
.th-loc-out .th-loc-pill.is-unconfirmed::before { border: 1.6px solid var(--th-limited-dot); background: linear-gradient(90deg, var(--th-limited-dot) 50%, transparent 50%); }
.th-loc-out .th-loc-pill.is-reported { color: var(--th-teal-800); background: var(--th-mint); box-shadow: none; }
.th-loc-out .th-loc-res-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 12px 0 0; padding: 0; }
.th-loc-out .th-loc-res-actions .th-loc-call { grid-column: auto; grid-row: auto; }
.th-loc-out .th-loc-report { display: inline-flex; align-items: center; font-size: 14px; color: var(--th-ink-500); }
.th-loc-out .th-loc-report-link {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 2px;
  font: 600 14px/1.2 var(--th-font); color: var(--th-ink-700); text-decoration: underline; text-underline-offset: 3px;
}
.th-loc-out .th-loc-res-note { margin: 10px 0 0; padding: 0; font-size: 14px; line-height: 1.55; color: var(--th-ink-500); }
.th-loc-out .th-loc-res + .th-loc-safety, .th-loc-out .th-loc-res-list + .th-loc-safety { margin-top: 14px; }

/* ── phone ──────────────────────────────────────────────────── */
@media (max-width: 760px) {
  .th-loc .th-loc-field, .th-loc .th-loc-submit { flex: 1 1 100%; width: 100%; }
  .th-loc-out .th-loc-h { font-size: 20px; }
  .th-loc-out .th-loc-step { padding: 16px 16px 14px; border-radius: 16px; }
  .th-loc-out .th-loc-step-h { font-size: 17px; gap: 10px; }
  .th-loc-out .th-loc-ph { grid-template-columns: minmax(0, 1fr); padding: 12px 12px 12px 14px; }
  .th-loc-out .th-loc-call { grid-column: 1; grid-row: auto; justify-self: stretch; margin-top: 10px; }
  .th-loc-out .th-loc-res-actions .th-loc-call { flex: 1 1 100%; margin-top: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .th-loc *, .th-loc-out * { transition-duration: .001ms !important; animation-duration: .001ms !important; }
}
