/* Caterman intake form v2.0.0 — shared styles for all 4 form variants. */
:root {
  --cm-bg: #ffffff;
  --cm-ink: #1a1a1a;
  --cm-ink-soft: #4a4a4a;
  --cm-muted: #8a8a8a;
  --cm-rule: #e3e3e0;
  --cm-rule-strong: #cfcfcb;
  --cm-primary: #a8252e;
  --cm-primary-deep: #861d24;
  --cm-primary-soft: rgba(168, 37, 46, 0.08);
  --cm-error: #b3261e;
  --cm-error-bg: #fdf3f2;
  --cm-soft-bg: #faf9f6;
  --cm-card-bg: #fbfaf6;
  --cm-font: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --cm-radius: 6px;
  --cm-radius-sm: 4px;
  --cm-pad: 56px;
  --cm-gap: 16px;
  --cm-input-h: 50px;
}

.cm-shell, .cm-shell * { box-sizing: border-box; }
.cm-shell {
  background: var(--cm-bg); color: var(--cm-ink);
  font-family: var(--cm-font); font-size: 15px; line-height: 1.55;
  width: 100%; max-width: 1180px; margin: 0 auto;
  padding: var(--cm-pad); border: 1px solid var(--cm-rule);
}

/* ── Hero ─────────────────────────────────────────────────────────── */
.cm-hero { padding-bottom: 22px; border-bottom: 1px solid var(--cm-rule); margin-bottom: 28px; }
.cm-heading { font-family: var(--cm-font); font-weight: 600; font-size: 28px; line-height: 1.2; color: var(--cm-ink); margin: 0 0 10px; letter-spacing: -0.005em; }
.cm-intro { font-size: 15px; line-height: 1.55; color: var(--cm-ink-soft); margin: 0; max-width: 720px; }

/* ── Sections ─────────────────────────────────────────────────────── */
.cm-section { margin: 30px 0 14px; display: flex; flex-direction: column; gap: 4px; }
.cm-section-label { font-size: 17px; font-weight: 600; color: var(--cm-ink); }
.cm-subsection { margin: 24px 0 12px; }
.cm-section-label-sm { font-size: 14px; font-weight: 600; color: var(--cm-ink); text-transform: uppercase; letter-spacing: 0.06em; }
.cm-section-hint { font-size: 13px; color: var(--cm-muted); }

/* ── Grid ─────────────────────────────────────────────────────────── */
.cm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--cm-gap); }
.cm-span-1 { grid-column: span 1; }
.cm-span-2 { grid-column: span 2; }
.cm-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.cm-label { font-size: 13px; font-weight: 500; color: var(--cm-ink); }
.cm-req { color: var(--cm-primary); margin-left: 2px; }
.cm-optional { color: var(--cm-muted); font-weight: 400; font-size: 12px; }
.cm-hint { font-size: 12px; color: var(--cm-muted); margin-top: 4px; line-height: 1.4; }
.cm-error { font-size: 12px; color: var(--cm-error); }

/* ── Inputs ───────────────────────────────────────────────────────── */
.cm-input {
  width: 100%; height: var(--cm-input-h); padding: 0 14px;
  border: 1px solid var(--cm-rule-strong); border-radius: var(--cm-radius-sm);
  background: var(--cm-bg); color: var(--cm-ink);
  font-family: var(--cm-font); font-size: 15px;
  transition: border-color 0.12s, box-shadow 0.12s;
  appearance: none; -webkit-appearance: none;
}
.cm-input::placeholder { color: var(--cm-muted); }
.cm-input:hover { border-color: var(--cm-ink-soft); }
.cm-input:focus { outline: none; border-color: var(--cm-ink); box-shadow: 0 0 0 1px var(--cm-ink); }
.cm-input.cm-input-error { border-color: var(--cm-error); }
.cm-input.cm-input-error:focus { box-shadow: 0 0 0 1px var(--cm-error); }
.cm-textarea { height: auto; padding: 12px 14px; resize: vertical; line-height: 1.5; min-height: 96px; font-family: var(--cm-font); }
input[type="time"].cm-input { padding-right: 6px; }
input[type="date"].cm-input { padding-right: 6px; }

.cm-select-wrap { position: relative; }
.cm-select { padding-right: 36px; cursor: pointer; }
.cm-chev { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--cm-ink-soft); }

/* ── Pattern selector ─────────────────────────────────────────────── */
.cm-pattern-group {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
  margin-top: 4px;
}
.cm-pattern-card {
  text-align: left; padding: 18px 18px;
  background: var(--cm-bg);
  border: 1px solid var(--cm-rule-strong); border-radius: var(--cm-radius);
  cursor: pointer; font-family: var(--cm-font); color: var(--cm-ink);
  display: flex; flex-direction: column; gap: 6px;
  transition: border-color 0.12s, background 0.12s, box-shadow 0.12s;
  min-height: 120px;
}
.cm-pattern-card:hover { border-color: var(--cm-ink-soft); background: var(--cm-soft-bg); }
.cm-pattern-card-on {
  border-color: var(--cm-primary); background: var(--cm-primary-soft);
  box-shadow: inset 0 0 0 1px var(--cm-primary);
}
.cm-pattern-card-on:hover { background: var(--cm-primary-soft); }
.cm-pattern-title { font-size: 15px; font-weight: 600; color: var(--cm-ink); }
.cm-pattern-sub { font-size: 13px; line-height: 1.5; color: var(--cm-ink-soft); }

/* ── Service / day cards ──────────────────────────────────────────── */
/* Service card is intentionally flat — no boxed background. Single-window
 * (Pattern A or 1st window in B/C) reads as plain inline form fields. Multi-
 * window stacks separated by a thin divider so users can scan multiple windows
 * without the visual weight of a "modal" per window. */
.cm-svc-list { display: flex; flex-direction: column; gap: 0; }
.cm-day-list { display: flex; flex-direction: column; gap: 18px; }

.cm-svc-card {
  background: transparent;
  border: none;
  padding: 14px 0 18px;
  animation: cm-fade 0.18s ease-out;
}
.cm-svc-list > .cm-svc-card + .cm-svc-card {
  border-top: 1px solid var(--cm-rule);
  margin-top: 4px;
  padding-top: 18px;
}

/* Day cards stay distinct (Pattern C needs the visual grouping per day). */
.cm-day-card {
  background: var(--cm-bg);
  border: 1px solid var(--cm-rule-strong); border-radius: var(--cm-radius);
  padding: 22px 20px;
  animation: cm-fade 0.18s ease-out;
}
.cm-day-card .cm-svc-list { margin-top: 8px; }

.cm-svc-header, .cm-day-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px; gap: 12px;
}
.cm-svc-title { font-size: 12px; font-weight: 600; color: var(--cm-muted); text-transform: uppercase; letter-spacing: 0.08em; }
.cm-day-title { font-size: 15px; font-weight: 600; color: var(--cm-ink); }

/* In single-window mode the section header above already says "Service details"
 * — drop the in-card title to avoid stacking two labels. */
.cm-svc-list[data-multi-svc="0"] > .cm-svc-card > .cm-svc-header { display: none; }

.cm-add {
  margin-top: 10px;
  background: var(--cm-bg); color: var(--cm-ink);
  border: 1px dashed var(--cm-rule-strong); border-radius: var(--cm-radius-sm);
  padding: 12px 16px; font-family: var(--cm-font); font-size: 13px; font-weight: 600;
  cursor: pointer; width: 100%;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}
.cm-add:hover { border-color: var(--cm-primary); color: var(--cm-primary); background: var(--cm-primary-soft); }
.cm-add:disabled { opacity: 0.5; cursor: not-allowed; border-style: solid; }
.cm-add:disabled:hover { border-color: var(--cm-rule-strong); color: var(--cm-ink); background: var(--cm-bg); }

.cm-remove {
  background: transparent; color: var(--cm-muted);
  border: 1px solid var(--cm-rule); border-radius: var(--cm-radius-sm);
  padding: 6px 12px; font-family: var(--cm-font); font-size: 12px; font-weight: 500;
  cursor: pointer; transition: color 0.12s, border-color 0.12s;
}
.cm-remove:hover { color: var(--cm-error); border-color: var(--cm-error); }

/* ── Pill button group (style + tier per service window) ──────────── */
.cm-pill-group {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.cm-pill {
  background: var(--cm-bg); color: var(--cm-ink);
  border: 1px solid var(--cm-rule-strong); border-radius: 999px;
  padding: 8px 16px; font-family: var(--cm-font); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: background 0.12s, color 0.12s, border-color 0.12s;
  white-space: nowrap;
}
.cm-pill:hover { border-color: var(--cm-ink-soft); }
.cm-pill-on { background: var(--cm-ink); color: white; border-color: var(--cm-ink); }
.cm-pill-on:hover { background: var(--cm-ink); border-color: var(--cm-ink); }

/* ── Tier detail copy (inline below tier pills) ───────────────────── */
.cm-tier-info {
  margin-top: 12px; padding: 16px 18px;
  background: var(--cm-soft-bg); border: 1px solid var(--cm-rule); border-radius: var(--cm-radius);
  animation: cm-fade 0.16s ease-out;
}
.cm-tier-info[hidden], .cm-tier-info[data-empty="1"] { display: none; }
.cm-tier-eyebrow {
  font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--cm-primary); font-weight: 600; margin-bottom: 4px;
}
.cm-tier-headline {
  font-size: 16px; font-weight: 600; color: var(--cm-ink);
  margin-bottom: 12px; line-height: 1.3;
}
.cm-tier-row {
  display: grid; grid-template-columns: 140px 1fr; gap: 16px;
  padding: 8px 0; border-top: 1px solid var(--cm-rule);
  font-size: 13px; line-height: 1.55;
}
.cm-tier-row:first-of-type { border-top: none; padding-top: 0; }
.cm-tier-key { font-weight: 600; color: var(--cm-ink); font-size: 13px; }
.cm-tier-val { color: var(--cm-ink-soft); }

/* Multi-window mode on desktop: keep the tier-info hidden by default to save
 * vertical space. Reveal on hover OR keyboard focus-within (so keyboard users
 * still get the copy when tabbing through pills). Mobile (no hover capability)
 * always shows inline — vertical scroll is cheap on phones. */
@media (hover: hover) and (min-width: 761px) {
  .cm-svc-list[data-multi-svc="1"] .cm-tier-info {
    display: none;
  }
  .cm-svc-list[data-multi-svc="1"] .cm-svc-card:hover .cm-tier-info,
  .cm-svc-list[data-multi-svc="1"] .cm-svc-card:focus-within .cm-tier-info {
    display: block;
  }
  /* Hint to the user that hovering reveals more — small "i" affordance on the
   * tier pill group label when in multi mode. */
  .cm-svc-list[data-multi-svc="1"] .cm-svc-card .cm-pill-group[data-tier-group]::after {
    content: '  ⓘ hover to see what this tier includes';
    display: inline-block;
    margin-left: 8px;
    font-size: 11px; color: var(--cm-muted); font-weight: 400;
    align-self: center;
  }
}

/* ── Recurring toggle ─────────────────────────────────────────────── */
.cm-toggle-row {
  display: grid; grid-template-columns: auto 1fr; column-gap: 12px; row-gap: 4px;
  padding: 14px 16px;
  background: var(--cm-soft-bg); border: 1px solid var(--cm-rule); border-radius: var(--cm-radius);
  cursor: pointer; user-select: none;
}
.cm-toggle-row input[type="checkbox"] {
  grid-row: 1 / span 2; align-self: center;
  width: 18px; height: 18px; accent-color: var(--cm-primary); cursor: pointer; margin: 0;
}
.cm-toggle-label { font-size: 14px; font-weight: 600; color: var(--cm-ink); }
.cm-toggle-sub { font-size: 13px; color: var(--cm-ink-soft); line-height: 1.45; }

/* ── Day count display ────────────────────────────────────────────── */
.cm-day-count {
  padding: 10px 14px;
  background: var(--cm-soft-bg); border: 1px solid var(--cm-rule); border-radius: var(--cm-radius-sm);
  font-size: 13px; font-weight: 500; color: var(--cm-ink-soft);
}
.cm-day-count-error { background: var(--cm-error-bg); border-color: #e7c7c5; color: var(--cm-error); }

/* ── Submit / banner / success ────────────────────────────────────── */
.cm-submit-row { margin-top: 32px; display: flex; justify-content: flex-end; }
.cm-submit {
  background: var(--cm-primary); color: white; border: none;
  font-family: var(--cm-font); font-size: 13px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase;
  padding: 0 40px; height: 50px; border-radius: var(--cm-radius-sm); cursor: pointer; transition: background 0.12s;
}
.cm-submit:hover { background: var(--cm-primary-deep); }
.cm-submit:disabled, .cm-submit[disabled] {
  background: var(--cm-rule-strong); color: #fff; cursor: not-allowed; opacity: 1;
}
.cm-submit:focus { outline: none; box-shadow: 0 0 0 2px var(--cm-primary-soft), 0 0 0 1px var(--cm-primary); }

.cm-banner {
  margin-bottom: 20px; padding: 12px 14px;
  border: 1px solid #e7c7c5; background: var(--cm-error-bg); color: #7a1a1f;
  border-radius: var(--cm-radius-sm); font-size: 14px;
}
.cm-banner a { color: inherit; text-decoration: underline; }

.cm-success { padding: 24px 0 8px; border-top: 1px solid var(--cm-rule); }
.cm-success-title { font-size: 22px; font-weight: 600; color: var(--cm-ink); margin: 0 0 8px; }
.cm-success-body { font-size: 15px; line-height: 1.55; color: var(--cm-ink-soft); max-width: 560px; margin: 0; }

/* ── Step transitions ─────────────────────────────────────────────── */
.cm-step[hidden] { display: none; }

@keyframes cm-fade {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Mobile ───────────────────────────────────────────────────────── */
/* Multi-day on iPhone Safari is the worst case — every card stacks vertically.
 * Pattern cards collapse to single column. Pill groups wrap naturally.
 * Service/day cards lose horizontal padding to give input controls room. */
@media (max-width: 760px) {
  :root { --cm-pad: 22px; --cm-gap: 14px; }
  .cm-shell { padding: var(--cm-pad); }
  .cm-heading { font-size: 22px; }
  .cm-grid { grid-template-columns: 1fr; }
  .cm-span-1, .cm-span-2 { grid-column: span 1; }
  .cm-pattern-group { grid-template-columns: 1fr; gap: 10px; }
  .cm-pattern-card { min-height: auto; padding: 14px 14px; }
  .cm-svc-card, .cm-day-card { padding: 14px 14px; }
  .cm-svc-header, .cm-day-header { flex-wrap: wrap; }
  .cm-submit { width: 100%; }
  .cm-submit-row { justify-content: stretch; }
  .cm-pill-group { gap: 6px; }
  .cm-pill { padding: 8px 12px; font-size: 13px; }
  /* Time inputs on iOS Safari are oddly tall — let them breathe but keep them
   * aligned with the text inputs in the grid. */
  input[type="time"].cm-input, input[type="date"].cm-input { padding: 0 10px; }
}
