/**
 * Kodiak service-area check.
 *
 * Colours come from the Elementor kit's globals so the control follows the site if the palette is
 * ever retuned, with the current values as fallbacks:
 *   primary #990000 · text #1C1C1C · secondary #474747 · accent #BFBFBF
 *
 * Everything is scoped under .kodiak-sa. Selects are reset explicitly rather than inheriting,
 * because Hello Elementor, Elementor Pro and Max Mega Menu all style form controls differently and
 * the control has to look the same in the navbar as it does on the homepage.
 */

.kodiak-sa {
  --ksa-primary: var(--e-global-color-primary, #990000);
  --ksa-text: var(--e-global-color-text, #1c1c1c);
  --ksa-muted: var(--e-global-color-secondary, #474747);
  --ksa-border: #d4d4d4;
  --ksa-bg: #ffffff;
  --ksa-radius: 4px;

  box-sizing: border-box;
  color: var(--ksa-text);
  font-family: inherit;
  max-width: 100%;
}

.kodiak-sa *,
.kodiak-sa *::before,
.kodiak-sa *::after {
  box-sizing: inherit;
}

/* ---------- heading / intro ---------- */

.kodiak-sa__heading {
  margin: 0 0 0.35em;
  font-size: 1.25rem;
  line-height: 1.2;
  color: var(--ksa-text);
}

.kodiak-sa__intro {
  margin: 0 0 1em;
  color: var(--ksa-muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

/* ---------- fields ---------- */

.kodiak-sa__fields {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.kodiak-sa__field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1 1 170px;
  min-width: 0; /* lets a flex child actually shrink inside a narrow menu panel */
}

.kodiak-sa__label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ksa-muted);
  line-height: 1.2;
}

.kodiak-sa__select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 100%;
  margin: 0;
  padding: 10px 34px 10px 12px;
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.3;
  color: var(--ksa-text);
  background-color: var(--ksa-bg);
  /* Chevron drawn inline so there is no image request and no dependency on a theme icon font. */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='%23474747' d='M1.4 0 6 4.6 10.6 0 12 1.4 6 7.4 0 1.4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 11px;
  border: 1px solid var(--ksa-border);
  border-radius: var(--ksa-radius);
  height: auto;
  cursor: pointer;
}

.kodiak-sa__select:focus-visible,
.kodiak-sa__submit:focus-visible {
  outline: 2px solid var(--ksa-primary);
  outline-offset: 2px;
}

.kodiak-sa__select:disabled {
  background-color: #f4f4f4;
  color: #8a8a8a;
  cursor: not-allowed;
}

/* ---------- submit ---------- */

.kodiak-sa__submit {
  flex: 0 0 auto;
  margin: 0;
  padding: 11px 22px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
  background: var(--ksa-primary);
  border: 1px solid var(--ksa-primary);
  border-radius: var(--ksa-radius);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.kodiak-sa__submit:hover:not(:disabled) {
  background: #7a0000;
  border-color: #7a0000;
}

.kodiak-sa__submit:disabled {
  background: #cfcfcf;
  border-color: #cfcfcf;
  cursor: not-allowed;
}

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

.kodiak-sa__result {
  display: none;
}

.kodiak-sa__result--visible {
  display: block;
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: var(--ksa-radius);
  border-left: 4px solid var(--ksa-primary);
  background: #f6f6f6;
}

/* Served and not-served are distinguished by the icon and the wording as well as the colour, so the
   answer does not depend on colour vision. */
.kodiak-sa__result--yes {
  border-left-color: #1f7a3d;
  background: #f1f8f3;
}

.kodiak-sa__result--no {
  border-left-color: var(--ksa-primary);
  background: #faf3f3;
}

.kodiak-sa__result-head {
  display: flex;
  align-items: baseline;
  gap: 9px;
  margin: 0 0 4px;
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.35;
}

.kodiak-sa__result-icon {
  flex: 0 0 auto;
  font-weight: 700;
}

.kodiak-sa__result--yes .kodiak-sa__result-icon { color: #1f7a3d; }
.kodiak-sa__result--no  .kodiak-sa__result-icon { color: var(--ksa-primary); }

.kodiak-sa__result-body {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--ksa-muted);
}

.kodiak-sa__cta {
  display: inline-block;
  margin-top: 10px;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ksa-primary);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.kodiak-sa__cta:hover,
.kodiak-sa__cta:focus {
  color: #7a0000;
}

/* ---------- compact (navbar) ---------- */

.kodiak-sa--compact {
  --ksa-radius: 3px;
  min-width: 260px;
}

.kodiak-sa--compact .kodiak-sa__fields {
  gap: 8px;
}

.kodiak-sa--compact .kodiak-sa__field {
  flex: 1 1 100%;
}

.kodiak-sa--compact .kodiak-sa__select {
  padding: 8px 30px 8px 10px;
  font-size: 0.88rem;
}

.kodiak-sa--compact .kodiak-sa__submit {
  width: 100%;
  padding: 9px 16px;
  font-size: 0.82rem;
}

.kodiak-sa--compact .kodiak-sa__result--visible {
  margin-top: 12px;
  padding: 11px 13px;
}

.kodiak-sa--compact .kodiak-sa__result-head { font-size: 0.9rem; }
.kodiak-sa--compact .kodiak-sa__result-body { font-size: 0.85rem; }

/* ---------- reveal-on-icon (navbar) ---------- */

.kodiak-sa--reveal {
  position: relative;
  display: inline-block;
}

.kodiak-sa__toggle {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  margin: 0;
  color: var(--ksa-text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--ksa-radius);
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.kodiak-sa__toggle:hover,
.kodiak-sa--reveal.is-open .kodiak-sa__toggle {
  color: var(--ksa-primary);
  background: rgba(153, 0, 0, 0.07);
}

.kodiak-sa__toggle:focus-visible {
  outline: 2px solid var(--ksa-primary);
  outline-offset: 2px;
}

.kodiak-sa__icon {
  width: 22px;
  height: 22px;
  display: block;
}

/* The panel is a popover anchored to the icon. z-index sits above Max Mega Menu's own dropdowns,
   which use 999 — without this it opens behind the menu it lives in. */
.kodiak-sa--reveal .kodiak-sa__panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 1001;
  width: 300px;
  max-width: calc(100vw - 32px);
  padding: 16px;
  background: var(--ksa-bg);
  border: 1px solid #e3e3e3;
  border-radius: var(--ksa-radius);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.14);
}

/* `hidden` alone loses to the display rules above in some themes; make it unambiguous. */
.kodiak-sa--reveal .kodiak-sa__panel[hidden] {
  display: none;
}

/* Little pointer up at the icon, so the panel reads as belonging to it. */
.kodiak-sa--reveal .kodiak-sa__panel::before {
  content: '';
  position: absolute;
  top: -7px;
  right: 13px;
  width: 12px;
  height: 12px;
  background: var(--ksa-bg);
  border-left: 1px solid #e3e3e3;
  border-top: 1px solid #e3e3e3;
  transform: rotate(45deg);
}

/* On a phone the navbar is narrow and an anchored popover would hang off-screen; pin it instead. */
@media (max-width: 600px) {
  .kodiak-sa--reveal .kodiak-sa__panel {
    position: fixed;
    top: auto;
    right: 16px;
    left: 16px;
    width: auto;
    max-width: none;
  }

  .kodiak-sa--reveal .kodiak-sa__panel::before {
    display: none;
  }
}

/* Max Mega Menu resets aggressively inside its panels and forces its own link colours; these win
   back the control's own appearance without using !important on everything. */
.mega-menu-item .kodiak-sa__select,
.mega-menu-item .kodiak-sa__submit {
  text-transform: none;
  line-height: 1.3;
}

.mega-menu-item .kodiak-sa__cta {
  color: var(--ksa-primary);
  text-transform: uppercase;
}

/* ---------- small screens ---------- */

@media (max-width: 600px) {
  .kodiak-sa__fields {
    gap: 10px;
  }

  .kodiak-sa__field,
  .kodiak-sa__submit {
    flex: 1 1 100%;
  }

  .kodiak-sa__submit {
    width: 100%;
  }
}
