/* ==========================================================================
   Site-wide "Contact Us" modal (contact-modal.php, js/contact-modal.js)
   Sharp (square-cornered) design, 3D flip in/out, compact two-column form.
   ========================================================================== */

.cm {
  --cm-navy: #282e67;
  --cm-blue: #1d4b98;
  --cm-sky: #3ea6ff;
  --cm-ink: #111827;
  --cm-muted: #5b6478;
  --cm-line: #d9e1ee;
  --cm-soft: #f4f7fc;
  --cm-red: #d92d20;
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  font-family: var(--font-primary, "Satoshi", sans-serif);
}
.cm[hidden] { display: none; }
.cm *, .cm *::before, .cm *::after { box-sizing: border-box; }

.cm__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 20, 50, 0.55);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.cm.is-open .cm__backdrop { opacity: 1; }

/* ---------- 3D flip ---------- */
.cm__stage {
  position: relative;
  width: min(640px, 100%);
  perspective: 1600px;
}
.cm__card {
  position: relative;
  transform-style: preserve-3d;
  transform: rotateY(-100deg) scale(0.92);
  opacity: 0;
  transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.35s ease;
}
.cm.is-open .cm__card { transform: rotateY(0) scale(1); opacity: 1; }
.cm.is-closing .cm__card { transform: rotateY(100deg) scale(0.92); opacity: 0; transition-duration: 0.45s; }
/* After a successful submit the card turns around to the thank-you side */
.cm.is-open.is-done .cm__card { transform: rotateY(180deg); }

.cm__face {
  background: #fff;
  border-radius: 0;                       /* sharp design */
  box-shadow: 0 30px 70px rgba(5, 15, 45, 0.35);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
}
.cm__face--back {
  position: absolute;
  inset: 0;
  transform: rotateY(180deg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 32px;
  text-align: center;
  border-top: 4px solid var(--cm-sky);
}

/* ---------- Header ---------- */
.cm__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
  background: linear-gradient(120deg, var(--cm-navy) 0%, var(--cm-blue) 100%);
  color: #fff;
  border-bottom: 3px solid var(--cm-sky);
}
.cm__head h2 { margin: 0; font-size: 1.35rem; font-weight: 700; color: #fff; letter-spacing: 0; line-height: 1.2; }
.cm__head p { margin: 4px 0 0; font-size: 0.88rem; color: #d6e2ff; text-align: left; line-height: 1.4; }
.cm__x {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 0;
  background: transparent;
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.25s ease;
}
.cm__x:hover { background: rgba(255, 255, 255, 0.15); transform: rotate(90deg); }

/* ---------- Form ---------- */
.cm__form { padding: 18px 24px 20px; }
.cm__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;        /* two fields per row */
  gap: 12px 16px;
}
.cm__field { display: flex; flex-direction: column; gap: 5px; margin: 0; min-width: 0; }
.cm__field--full { grid-column: 1 / -1; } /* dropdown, "specify" and message take a full row */
.cm__field[hidden] { display: none; }
.cm__field > span, .cm__field > span#cmSvcLabel {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--cm-navy);
  text-align: left;
}
.cm__field b { color: var(--cm-red); font-weight: 700; }
.cm__field em { font-style: normal; font-weight: 500; color: var(--cm-muted); }

.cm input[type="text"],
.cm input[type="email"],
.cm input[type="tel"],
.cm textarea,
.cm-select__toggle {
  width: 100%;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--cm-line);
  border-radius: 0;
  background: #fff;
  color: var(--cm-ink);
  font: 500 0.92rem/1.35 var(--font-primary, "Satoshi", sans-serif);
  box-shadow: none;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.cm textarea { resize: vertical; min-height: 72px; }
.cm input:focus, .cm textarea:focus, .cm-select__toggle:focus-visible, .cm-select.is-open .cm-select__toggle {
  border-color: var(--cm-blue);
  box-shadow: 0 0 0 3px rgba(29, 75, 152, 0.15);
}
.cm .is-invalid { border-color: var(--cm-red) !important; }
.cm__err { min-height: 0; font-size: 0.75rem; color: var(--cm-red); text-align: left; }
.cm__err:empty { display: none; }
.cm__trap { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; opacity: 0; }

/* ---------- Multi-select dropdown ---------- */
.cm-select { position: relative; }
.cm-select__toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 42px;
  cursor: pointer;
  text-align: left;
}
.cm-select__toggle i { color: var(--cm-blue); font-size: 12px; transition: transform 0.2s ease; }
.cm-select.is-open .cm-select__toggle i { transform: rotate(180deg); }
.cm-select__value { display: flex; flex-wrap: wrap; gap: 6px; color: var(--cm-muted); }
.cm-select__chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  background: var(--cm-blue);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
}
.cm-select__menu {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  z-index: 5;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--cm-line);
  box-shadow: 0 16px 34px rgba(17, 24, 39, 0.16);
}
.cm-select__menu[hidden] { display: none; }
.cm-select__opt {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 9px 10px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--cm-ink);
  cursor: pointer;
  transition: background-color 0.15s ease;
}
.cm-select__opt:hover { background: var(--cm-soft); }
.cm-select__opt input { position: absolute; opacity: 0; pointer-events: none; }
.cm-select__box {
  display: grid;
  place-items: center;
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  border: 1.5px solid #9aa7c2;
  background: #fff;
  color: transparent;
  font-size: 11px;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.cm-select__opt input:checked + .cm-select__box { background: var(--cm-blue); border-color: var(--cm-blue); color: #fff; }
.cm-select__opt input:focus-visible + .cm-select__box { outline: 2px solid var(--cm-sky); outline-offset: 2px; }

/* ---------- Consent, alert ---------- */
.cm__consent {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 14px 0 0;
  font-size: 0.76rem;
  line-height: 1.45;
  color: var(--cm-muted);
  text-align: left;
  cursor: pointer;
}
.cm__consent input { flex: 0 0 auto; width: 16px; height: 16px; margin: 1px 0 0; accent-color: var(--cm-blue); }
.cm__consent a { color: var(--cm-blue); font-weight: 600; text-decoration: underline; }
.cm__alert { margin: 10px 0 0; padding: 8px 12px; background: #fdecea; border-left: 3px solid var(--cm-red); color: #8a1c13; font-size: 0.85rem; text-align: left; }

/* ---------- Buttons ---------- */
.cm__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--cm-line);
}
.cm__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 120px;
  padding: 11px 20px;
  border: 1px solid transparent;
  border-radius: 0;
  font: 700 0.92rem/1 var(--font-primary, "Satoshi", sans-serif);
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}
.cm__btn:focus-visible { outline: 2px solid var(--cm-sky); outline-offset: 2px; }
.cm__btn--ghost { background: #fff; border-color: var(--cm-line); color: var(--cm-navy); }
.cm__btn--ghost:hover { border-color: var(--cm-navy); }
.cm__btn--primary { background: var(--cm-blue); border-color: var(--cm-blue); color: #fff; }
.cm__btn--primary:hover { background: var(--cm-navy); border-color: var(--cm-navy); transform: translateY(-1px); box-shadow: 0 8px 18px rgba(29, 75, 152, 0.3); }
.cm__btn--primary:hover i.fa-paper-plane { animation: cm-plane 0.6s ease; }
.cm__btn[disabled] { opacity: 0.7; cursor: wait; transform: none; }
@keyframes cm-plane { 50% { transform: translate(3px, -3px); } }

/* ---------- Thank-you side ---------- */
.cm__ok {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  background: #e8f6ee;
  color: #16a34a;
  font-size: 28px;
}
.cm__face--back h2 { margin: 6px 0 0; font-size: 1.5rem; color: var(--cm-navy); }
.cm__thanks { margin: 0 0 12px; max-width: 420px; color: var(--cm-muted); font-size: 0.95rem; line-height: 1.6; text-align: center; }

/* ---------- Small screens: one column ---------- */
@media (max-width: 575.98px) {
  .cm { padding: 10px; }
  .cm__grid { grid-template-columns: 1fr; gap: 10px; }
  .cm__head { padding: 14px 16px; }
  .cm__form { padding: 14px 16px 16px; }
  .cm-select__menu { grid-template-columns: 1fr; }
  .cm__actions { gap: 8px; }
  .cm__btn { flex: 1; min-width: 0; }
}

/* Short laptop screens: keep everything visible without scrolling */
@media (min-width: 576px) and (max-height: 720px) {
  .cm__head p { display: none; }
  .cm textarea { min-height: 56px; }
}

@media (prefers-reduced-motion: reduce) {
  .cm__card, .cm__backdrop { transition: opacity 0.2s ease; transform: none !important; }
  .cm.is-open.is-done .cm__face--front { display: none; }
  .cm.is-open.is-done .cm__face--back { position: static; transform: none; }
}

body.cm-lock { overflow: hidden; }

/* Tall enough screens: no inner scrollbar, and the dropdown can overflow the card */
@media (min-width: 576px) and (min-height: 760px) {
  .cm__face--front { max-height: none; overflow: visible; }
}
