/* Active Fibre coverage widget.
 *
 * Deliberately styled ONLY from theme custom properties, with fallbacks that
 * cover both demo themes' token names (v5/Bounce uses --paper/--tint, v4/Pulse
 * uses --bg/--surface). Dropping this file into either theme inherits that
 * theme's palette instead of introducing a third one — the brand red and the
 * FNO colours are constants and must not be re-invented here.
 */

.af-cov {
  --_paper: var(--paper, var(--bg-raised, #fff));
  --_tint:  var(--tint,  var(--surface, #f4f5f7));
  --_ink:   var(--ink,   #16181c);
  --_muted: var(--muted, #5b616c);
  --_line:  var(--line,  var(--border, #e2e4e8));
  --_accent: var(--accent, #c62828);
  --_accent-ink: var(--accent-ink, #fff);
  --_radius: var(--radius, 12px);

  /* Centred modal overlay. Previously the widget rendered inline in the footer
   * and the opener scrolled to it — on the home page that meant scrolling past
   * the whole footer to reach it. As a fixed overlay it opens over the page
   * wherever the visitor is, from any trigger (hero, nav, FTTH/FNO CTAs). */
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(16px, 5vh, 56px) 16px;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.62);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  color: var(--_ink);
  font-family: var(--font-body, inherit);
  text-align: left;
}

/* An explicit `display` on any rule below beats the UA's [hidden]{display:none},
 * so hidden must win explicitly (the overlay is display:flex). */
.af-cov[hidden],
.af-cov [hidden] { display: none !important; }

.af-cov-panel {
  position: relative;
  background: var(--_paper);
  border: 1px solid var(--_line);
  border-radius: var(--_radius);
  padding: clamp(20px, 4vw, 32px);
  max-width: 600px;
  width: 100%;
  margin: auto;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
}
.af-cov-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--_muted);
  font-size: 1.7rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 8px;
}
.af-cov-close:hover { color: var(--_ink); background: var(--_tint); }
.af-cov-close:focus-visible { outline: 2px solid var(--_accent); outline-offset: 1px; }

.af-cov h3 {
  font-family: var(--font-display, inherit);
  margin: 0 0 6px;
  font-size: clamp(1.15rem, 2.4vw, 1.5rem);
  color: var(--_ink);
}
.af-cov .af-cov-sub { margin: 0 0 18px; color: var(--_muted); font-size: 0.95rem; }

/* ── steps ─────────────────────────────────────────────────────────────── */
.af-cov-step[hidden] { display: none; }

.af-cov-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.af-cov-field label { font-size: 0.82rem; font-weight: 600; color: var(--_muted); }

.af-cov input[type="text"],
.af-cov input[type="email"],
.af-cov input[type="tel"] {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--_line);
  border-radius: var(--radius-sm, 8px);
  background: var(--_paper);
  color: var(--_ink);
  font: inherit;
  font-size: 1rem; /* 16px minimum — anything smaller zooms the page on iOS */
}
.af-cov input:focus-visible {
  outline: 2px solid var(--_accent);
  outline-offset: 1px;
}
.af-cov input[aria-invalid="true"] { border-color: var(--_accent); }

/* ── segment toggle ────────────────────────────────────────────────────── */
.af-cov-seg { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.af-cov-seg button {
  flex: 1 1 130px;
  padding: 11px 16px;
  border: 1px solid var(--_line);
  border-radius: var(--radius-sm, 8px);
  background: var(--_tint);
  color: var(--_ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.af-cov-seg button[aria-pressed="true"] {
  background: var(--_accent);
  border-color: var(--_accent);
  color: var(--_accent-ink);
}

/* ── map ───────────────────────────────────────────────────────────────── */
.af-cov-map {
  height: 260px;
  border-radius: var(--radius-sm, 8px);
  border: 1px solid var(--_line);
  margin-bottom: 8px;
  background: var(--_tint);
}
.af-cov-map[hidden] { display: none; }
.af-cov-hint { font-size: 0.8rem; color: var(--_muted); margin: 0 0 16px; }

/* ── buttons ───────────────────────────────────────────────────────────── */
.af-cov-btn {
  display: inline-block;
  padding: 13px 26px;
  border: 0;
  border-radius: var(--radius-sm, 8px);
  background: var(--_accent);
  color: var(--_accent-ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.af-cov-btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.af-cov-btn-quiet {
  background: transparent;
  color: var(--_muted);
  border: 1px solid var(--_line);
  font-weight: 600;
}

/* ── progress ──────────────────────────────────────────────────────────── */
/* The provider takes 3.5-5.0s. A bare spinner reads as hung at that length,
   so this shows determinate-looking progress and names what is happening. */
.af-cov-progress { padding: 8px 0 4px; }
.af-cov-bar {
  height: 5px;
  border-radius: 3px;
  background: var(--_tint);
  overflow: hidden;
  margin-bottom: 10px;
}
.af-cov-bar i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--_accent);
  transition: width 0.4s linear;
}
.af-cov-progress p { margin: 0; color: var(--_muted); font-size: 0.9rem; }

/* ── results ───────────────────────────────────────────────────────────── */
.af-cov-note {
  padding: 14px 16px;
  border-radius: var(--radius-sm, 8px);
  border: 1px solid var(--_line);
  background: var(--_tint);
  margin-bottom: 16px;
  font-size: 0.94rem;
}
.af-cov-note strong { display: block; margin-bottom: 3px; color: var(--_ink); }
.af-cov-note.is-warn { border-left: 3px solid var(--_accent); }

.af-cov-products { display: grid; gap: 10px; margin: 0 0 18px; padding: 0; list-style: none; }
.af-cov-product {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  padding: 14px 16px;
  border: 1px solid var(--_line);
  border-radius: var(--radius-sm, 8px);
  background: var(--_paper);
  cursor: pointer;
}
.af-cov-product:has(input:checked) {
  border-color: var(--_accent);
  box-shadow: inset 0 0 0 1px var(--_accent);
}
.af-cov-product input { margin: 0; accent-color: var(--_accent); }
.af-cov-product-main { flex: 1 1 190px; min-width: 0; }
.af-cov-product-name { font-weight: 700; display: block; }
.af-cov-product-speed {
  font-family: var(--font-mono, monospace);
  font-size: 0.82rem;
  color: var(--_muted);
}
.af-cov-product-price { font-weight: 700; font-size: 1.05rem; white-space: nowrap; }
.af-cov-product-price span { display: block; font-size: 0.72rem; font-weight: 400; color: var(--_muted); }

/* Staff-curated merchandising flags — reuse the widget's own accent token,
   never a new colour, per this file's palette-portability rule. */
.af-cov-badge {
  display: inline-block;
  margin: 0 6px 4px 0;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  vertical-align: middle;
}
.af-cov-badge-popular {
  background: var(--_accent);
  color: var(--_accent-ink);
}
.af-cov-badge-promo {
  background: transparent;
  color: var(--_accent);
  border: 1px solid var(--_accent);
}

.af-cov-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.af-cov-done { text-align: center; padding: 12px 0; }
.af-cov-ref {
  font-family: var(--font-mono, monospace);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--_accent);
  display: block;
  margin: 10px 0;
}

@media (max-width: 560px) {
  .af-cov { padding: 18px 16px; }
  .af-cov-map { height: 200px; }
  .af-cov-actions .af-cov-btn { width: 100%; }
}

.af-cov-turnstile:not(:empty) { margin-bottom: 14px; }

/* ── onboarding: mandate + optional-field label ─────────────────────────── */
.af-cov-mandate {
  white-space: pre-wrap;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--_ink);
  background: var(--_tint);
  border: 1px solid var(--_line);
  border-radius: var(--radius-sm, 8px);
  padding: 14px 16px;
  max-height: 240px;
  overflow-y: auto;
  margin-bottom: 14px;
}
.af-cov-opt { color: var(--_muted); font-weight: 400; }

/* Dropdowns (bank, account type) match the text inputs. */
.af-cov select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--_line);
  border-radius: var(--radius-sm, 8px);
  background: var(--_paper);
  color: var(--_ink);
  font: inherit;
  font-size: 1rem;
}
.af-cov select:focus-visible { outline: 2px solid var(--_accent); outline-offset: 1px; }

/* ── identity type + FICA documents ──────────────────────────────────────────
   Styled only from the widget's own token aliases, same rule as everything
   above: this file must render correctly in any theme's palette without a
   per-theme stylesheet. No literal brand colours here. */

.af-cov-idtype { display: flex; flex-wrap: wrap; gap: 10px; }

.af-cov-idtype-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 200px;
  padding: 11px 14px;
  border: 1px solid var(--_line);
  border-radius: var(--radius-sm, 8px);
  background: var(--_tint);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--_ink);
}

/* The whole tile reads as selected, not just the dot — at a glance the
   customer needs to see which identity document they are about to be asked
   for, since that decides what they have to go and find. */
.af-cov-idtype-opt:has(input:checked) {
  border-color: var(--_accent);
  box-shadow: inset 0 0 0 1px var(--_accent);
}
.af-cov-idtype-opt:focus-within { outline: 2px solid var(--_accent); outline-offset: 1px; }
.af-cov-idtype-opt input { accent-color: var(--_accent); flex: none; }

/* The document notice. Accented rather than quiet: it is the one thing on the
   step the customer has to act on later, and burying it is how it gets missed. */
.af-cov-docs {
  border: 1px solid var(--_line);
  border-left: 4px solid var(--_accent);
  border-radius: var(--radius-sm, 8px);
  background: var(--_tint);
  padding: 14px 16px;
  margin: 16px 0 4px;
}
.af-cov-docs strong { display: block; margin-bottom: 6px; color: var(--_ink); font-size: 0.95rem; }
.af-cov-docs p { margin: 0 0 8px; color: var(--_muted); font-size: 0.86rem; line-height: 1.55; }
.af-cov-docs ul { margin: 0; padding-left: 18px; color: var(--_ink); font-size: 0.86rem; line-height: 1.7; }

.af-cov-done .af-cov-docs { margin-top: 20px; text-align: left; }

/* ── business enquiry: requirements textarea + services checkboxes ───────── */
.af-cov textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--_line);
  border-radius: var(--radius-sm, 8px);
  background: var(--_paper);
  color: var(--_ink);
  font: inherit;
  font-size: 1rem; /* 16px min — smaller zooms the page on iOS */
  resize: vertical;
  min-height: 84px;
}
.af-cov textarea:focus-visible { outline: 2px solid var(--_accent); outline-offset: 1px; }

.af-cov-services {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  border: 1px solid var(--_line);
  border-radius: var(--radius-sm, 8px);
  padding: 14px;
  background: var(--_tint);
}
.af-cov-svc-group { display: flex; flex-direction: column; gap: 7px; }
.af-cov-svc-head {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--_accent);
}
.af-cov-services label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--_ink);
  cursor: pointer;
  line-height: 1.4;
}
.af-cov-services input[type="checkbox"] { margin-top: 2px; flex: none; accent-color: var(--_accent); }

/* ── feasible-FNO chips (business coverage result) ───────────────────────── */
.af-cov-fnos { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 16px; }
.af-cov-fnos-label { width: 100%; font-size: 0.8rem; font-weight: 600; color: var(--_muted); margin-bottom: 2px; }
.af-cov-fno-chip {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--_line);
  background: var(--_tint);
  color: var(--_ink);
  font-size: 0.85rem;
  font-weight: 600;
}

/* ── connection type: Broadband / DIA / Not sure ─────────────────────────── */
.af-cov-conntype { display: flex; flex-direction: column; gap: 8px; }
.af-cov-conn-opt {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--_line);
  border-radius: var(--radius-sm, 8px);
  background: var(--_paper);
  cursor: pointer;
}
.af-cov-conn-opt input { margin-top: 3px; flex: none; accent-color: var(--_accent); }
.af-cov-conn-opt span { display: flex; flex-direction: column; gap: 2px; }
.af-cov-conn-opt strong { font-size: 0.92rem; color: var(--_ink); font-weight: 600; }
.af-cov-conn-opt em { font-style: normal; font-size: 0.8rem; color: var(--_muted); line-height: 1.4; }
.af-cov-conn-opt:has(input:checked) { border-color: var(--_accent); box-shadow: 0 0 0 1px var(--_accent); }

/* ── Google Places autocomplete dropdown ─────────────────────────────────────
   Google appends `.pac-container` to <body>, OUTSIDE this widget's DOM, with a
   hard-coded `z-index: 1000`. The widget is a modal at `z-index: 9999`, so the
   dropdown paints *behind* the panel: the predictions are in the DOM and
   correctly positioned, but a click on one lands on the modal instead.

   That breaks the whole funnel, not just the dropdown — selecting a prediction
   is what fires `place_changed`, which is the only thing that sets
   `state.lat`/`state.lng`. Without it every "Check coverage" click stops at the
   "Enter your address first" guard, which reads to a customer as "it isn't
   checking my address".

   Must be a global selector, not scoped under `.af-cov` — the element is not a
   descendant of the widget. Keep this ABOVE whatever the modal's z-index is; if
   that value ever changes, change this one with it. */
.pac-container {
  z-index: 10000 !important;
}

/* Google's own dropdown styling is light-on-white and hard-codes its text
   colours, which is fine here — it sits over the panel, not inside it — but the
   attribution row needs to not collide with a dark theme. */
.pac-container .pac-item { cursor: pointer; }

/* ── router opt-out, upfront payment, free audit ─────────────────────────────
   Token-only styling, same portability rule as the rest of this file. */

/* The router block states what the customer GETS; the checkbox is the opt-out.
   Styled as an inclusion, not a warning — most people should read it and move
   on without touching anything. */
.af-cov-router {
  border: 1px solid var(--_line);
  border-radius: var(--radius-sm, 8px);
  background: var(--_tint);
  padding: 14px 16px;
  margin: 4px 0 14px;
}
.af-cov-router strong { display: block; margin-bottom: 5px; color: var(--_ink); font-size: 0.95rem; }
.af-cov-router p { margin: 0 0 10px; color: var(--_muted); font-size: 0.85rem; line-height: 1.55; }
.af-cov-router label {
  display: flex; align-items: flex-start; gap: 9px;
  color: var(--_ink); font-size: 0.88rem; font-weight: 500; cursor: pointer;
}
.af-cov-router input { accent-color: var(--_accent); margin-top: 2px; flex: none; }

/* Money the customer has to find before installation. Accented, because
   discovering this on a phone call after handing over bank details is the
   single most avoidable complaint this form can generate. */
.af-cov-upfront {
  border: 1px solid var(--_line);
  border-left: 4px solid var(--_accent);
  border-radius: var(--radius-sm, 8px);
  background: var(--_tint);
  padding: 14px 16px;
  margin: 0 0 18px;
}
.af-cov-upfront strong { display: block; margin-bottom: 5px; color: var(--_ink); font-size: 0.95rem; }
.af-cov-upfront p { margin: 0; color: var(--_muted); font-size: 0.85rem; line-height: 1.55; }

/* The free audit leads the service list, so it gets the accent the paid
   options do not. */
.af-cov-svc-free {
  border: 1px solid var(--_accent);
  border-radius: var(--radius-sm, 8px);
  padding: 10px 12px;
  background: var(--_tint);
}
.af-cov-svc-free strong { color: var(--_ink); }
