/*
 * GrantCheck widget.
 *
 * Brand tokens are CSS custom properties so an installer's own colours can be
 * injected per widget. Defaults are the InstallerHQ palette; --brand-ink is a
 * separately-tuned darker green for text on white, because the brand green
 * itself does not meet contrast requirements as body text.
 */

:root {
  --brand: #7ac943;
  --brand-dark: #4f8f2f;
  --brand-ink: #3c7a22;
  --ink: #111111;
  --muted: #5b6670;
  --line: #e4e8ec;
  --line-soft: #eef1f4;
  --surface: #ffffff;
  --canvas: #f6f8f9;
  --warn-ink: #8a5a00;
  --warn-bg: #fff8e6;
  --stop-ink: #8a2c2c;
  --stop-bg: #fdf1f1;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 18px 44px -26px rgba(17, 17, 17, 0.4);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--canvas);
  color: var(--ink);
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.gc {
  max-width: 520px;
  margin: 0 auto;
  padding: 20px 16px 28px;
}

.gc-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* --- progress ------------------------------------------------------------ */

.gc-progress {
  height: 4px;
  background: var(--line-soft);
}

.gc-progress i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--brand), var(--brand-dark));
  transition: width 0.45s var(--ease);
}

.gc-body {
  padding: 26px 24px 24px;
}

/* --- typography ---------------------------------------------------------- */

.gc-step-label {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand-ink);
  margin-bottom: 10px;
}

.gc-h {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.gc-sub {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

/* --- form controls ------------------------------------------------------- */

.gc-field {
  margin-top: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  background: var(--surface);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.gc-field:focus-within {
  border-color: var(--brand-dark);
  box-shadow: 0 0 0 3px rgba(122, 201, 67, 0.25);
}

.gc-field input {
  flex: 1;
  border: 0;
  outline: 0;
  padding: 15px 0;
  font: inherit;
  color: inherit;
  background: transparent;
  min-width: 0;
}

.gc-field input::placeholder {
  color: #9aa4ad;
}

.gc-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 16px;
  padding: 15px 18px;
  border: 0;
  border-radius: var(--radius-sm);
  background: linear-gradient(160deg, var(--brand), var(--brand-dark));
  color: #ffffff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.18s var(--ease), box-shadow 0.18s, filter 0.18s;
  box-shadow: 0 10px 22px -12px rgba(79, 143, 47, 0.9);
}

.gc-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: saturate(1.08);
}

.gc-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.gc-btn:focus-visible,
.gc-option:focus-visible,
.gc-link:focus-visible,
.gc-back:focus-visible {
  outline: 3px solid var(--brand-dark);
  outline-offset: 2px;
}

/* --- option lists -------------------------------------------------------- */

.gc-options {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.gc-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 15px 16px;
  text-align: left;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font: inherit;
  color: inherit;
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s, transform 0.18s var(--ease);
}

.gc-option:hover {
  border-color: var(--brand);
  background: #fbfdf9;
  transform: translateY(-1px);
}

.gc-option span.gc-option-sub {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 500;
  margin-top: 2px;
}

.gc-option strong {
  font-weight: 700;
}

.gc-option-chevron {
  flex: 0 0 auto;
  color: var(--brand-dark);
}

.gc-yesno {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

.gc-yesno .gc-option {
  justify-content: center;
  font-weight: 700;
}

/* --- helper text --------------------------------------------------------- */

.gc-help {
  margin-top: 14px;
  padding: 12px 14px;
  background: var(--canvas);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  color: var(--muted);
}

.gc-why {
  margin-top: 12px;
  font-size: 0.85rem;
}

.gc-why summary {
  cursor: pointer;
  color: var(--brand-ink);
  font-weight: 600;
}

.gc-why p {
  margin: 8px 0 0;
  color: var(--muted);
}

.gc-back {
  /* Block-level flex so the step label that follows starts on its own line
     rather than colliding with the back control. */
  display: flex;
  width: max-content;
  align-items: center;
  gap: 6px;
  border: 0;
  background: none;
  padding: 4px 0;
  margin-bottom: 8px;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.gc-back:hover {
  color: var(--ink);
}

.gc-link {
  display: block;
  width: 100%;
  margin-top: 14px;
  border: 0;
  background: none;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--brand-ink);
  cursor: pointer;
  text-align: center;
}

/* --- result -------------------------------------------------------------- */

.gc-result-lead {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.gc-amount {
  margin: 6px 0 0;
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--ink);
}

.gc-amount.gc-amount-range {
  font-size: 2.1rem;
}

.gc-tag {
  display: inline-block;
  margin-top: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(122, 201, 67, 0.16);
  color: var(--brand-ink);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.gc-scheme {
  margin-top: 10px;
  font-weight: 700;
}

.gc-detail {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.95rem;
}

.gc-panel {
  margin-top: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.gc-panel h3 {
  margin: 0 0 4px;
  font-size: 0.95rem;
  font-weight: 700;
}

.gc-panel p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.gc-panel.gc-panel-warn {
  background: var(--warn-bg);
  border-color: #f0e0b8;
}

.gc-panel.gc-panel-warn h3 {
  color: var(--warn-ink);
}

.gc-panel.gc-panel-stop {
  background: var(--stop-bg);
  border-color: #f0cfcf;
}

.gc-panel.gc-panel-stop h3 {
  color: var(--stop-ink);
}

.gc-reasons {
  margin: 10px 0 0;
  padding-left: 18px;
  font-size: 0.9rem;
  color: var(--muted);
}

.gc-reasons li + li {
  margin-top: 4px;
}

.gc-foot {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
  font-size: 0.78rem;
  color: var(--muted);
}

/* --- loading ------------------------------------------------------------- */

.gc-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 26px 0;
  text-align: center;
}

.gc-spinner {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--brand-dark);
  animation: gc-spin 0.9s linear infinite;
}

@keyframes gc-spin {
  to {
    transform: rotate(360deg);
  }
}

.gc-step {
  animation: gc-in 0.4s var(--ease);
}

@keyframes gc-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.gc-error {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--stop-bg);
  border: 1px solid #f0cfcf;
  color: var(--stop-ink);
  font-size: 0.9rem;
}

.gc-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --- narrow screens ------------------------------------------------------ */

@media (max-width: 380px) {
  .gc {
    padding: 12px 10px 20px;
  }
  .gc-body {
    padding: 20px 16px 18px;
  }
  .gc-h {
    font-size: 1.25rem;
  }
  .gc-amount {
    font-size: 2.4rem;
  }
  .gc-amount.gc-amount-range {
    font-size: 1.6rem;
  }
  .gc-yesno {
    grid-template-columns: 1fr;
  }
}

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

/* Long address lists (a postcode can hold 40+ certificated properties) get a
   scroll region rather than pushing the action off the bottom of the iframe. */
.gc-options.gc-options-scroll {
  max-height: 46vh;
  min-height: 220px;
  overflow-y: auto;
  padding-right: 4px;
  overscroll-behavior: contain;
}
