/*
 * Mabery Studios UX components: sticky CTA, header show/hide, carousel, full-page booking form,
 * inline first step, call status. Rules: BUILD-RULES.md. Reference build: Desktop\mcdermott plumbing.
 * Map these tokens to the client's design system (keep roles: --ux-accent is CTA-only).
 */
:root {
  --ux-ink: #163300;          /* primary dark: bar background, selected states, progress */
  --ux-paper: #ffffff;
  --ux-muted: #e8ebe6;        /* soft surface */
  --ux-tint: #e2f6d5;         /* hover / selected answer fill */
  --ux-line: #868685;         /* input and tile borders */
  --ux-text: #454745;
  --ux-heading: #0e0f0c;
  --ux-accent: #9fe870;       /* CTA only */
  --ux-alarm: #cb272f;
  --ux-focus: #1b3a7a;
  --ux-on-dark: #d9e3d2;
  --ux-rule-on-dark: rgb(255 255 255 / .14);
  --ux-pill: 9999px; --ux-radius: 12px; --ux-radius-lg: 28px;
  --ux-lift: 0 1px 2px rgb(14 15 12 / .10), 0 22px 44px -16px rgb(14 15 12 / .45);
  --ux-ease: cubic-bezier(.2, .7, .2, 1); --ux-ease-out: cubic-bezier(.16, 1, .3, 1);
  --ux-gutter: clamp(16px, 4vw, 32px);
  --ux-font: system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-reduced-motion: reduce) {
  .site-header, .mobile-bar, .bk-opt, .carousel-dot::before, .bk-progress span, .btn::after { transition: none; }
}

/* ---------- Header show/hide (js/main.js) ---------- */
.site-header { position: sticky; top: 0; z-index: 50; background: var(--ux-paper); transition: transform 350ms var(--ux-ease-out); }
.site-header.is-hidden { transform: translateY(-100%); }
.bk-lock .site-header { visibility: hidden; }

/* ---------- Sticky CTA (class kept as .mobile-bar) ----------
   A bottom bar at every width. main.js adds .is-shown (rules there). Call shows only during
   answering hours (html.calls-open); otherwise one full-width "Book a visit" button. */
.mobile-bar {
  position: fixed; z-index: 60; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: center; gap: 8px;
  padding: 8px max(16px, calc((100% - 560px) / 2)) calc(8px + env(safe-area-inset-bottom));
  background: var(--ux-ink); border-top: 1px solid var(--ux-rule-on-dark);
  transform: translateY(100%); visibility: hidden;
  transition: transform 350ms var(--ux-ease-out), visibility 0s linear 350ms;
}
.mobile-bar.is-shown { transform: none; visibility: visible; transition: transform 350ms var(--ux-ease-out), visibility 0s; }
.mobile-bar .btn { flex: 1; min-height: 52px; }
.mobile-bar .btn-outline { background: transparent; color: var(--ux-paper); border-color: var(--ux-paper); }
html:not(.calls-open) .mobile-bar a[href^="tel:"] { display: none; }
html:not(.calls-open) .mobile-bar .btn-outline { background: var(--ux-accent); color: var(--ux-ink); border-color: transparent; box-shadow: none; --sweep: rgb(255 255 255 / .6); }
/* The footer's legal line is never hidden under the bar. */
.has-sticky-cta .site-footer { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
/* Jump links and focused items never land under the header or the bar. */
html { scroll-padding-top: 96px; }
.has-sticky-cta { scroll-padding-bottom: 80px; }

/* ---------- Carousel (reviews) ---------- */
.carousel { --per: 3; --gap: 16px; position: relative; outline: none; }
.carousel:focus-visible { outline: 3px solid var(--ux-focus); outline-offset: 8px; border-radius: var(--ux-radius); }
.carousel-viewport { overflow: hidden; touch-action: pan-y; cursor: grab; user-select: none; -webkit-user-select: none; }
.carousel.is-dragging .carousel-viewport { cursor: grabbing; }
.carousel-track { display: flex; gap: var(--gap); will-change: transform; }
.carousel-track > * { flex: 0 0 calc((100% - (var(--per) - 1) * var(--gap)) / var(--per)); }
.carousel-track img { pointer-events: none; }
@media (max-width: 960px) { .carousel { --per: 2; } }
@media (max-width: 640px) { .carousel { --per: 1; } }
.carousel-controls { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 24px; }
.carousel-btn { width: 44px; height: 44px; border-radius: 50%; border: 1px solid rgb(14 15 12 / .12); background: var(--ux-paper); color: var(--ux-ink); display: grid; place-items: center; cursor: pointer; transition: background-color 150ms var(--ux-ease); }
.carousel-btn:hover { background: var(--ux-tint); }
.carousel-btn svg { width: 18px; height: 18px; }
.carousel-prev svg { transform: rotate(180deg); }
.carousel-dots { display: flex; align-items: center; touch-action: none; cursor: pointer; padding: 0 4px; }
.carousel-dot { width: 24px; height: 44px; padding: 0; border: 0; background: none; display: grid; place-items: center; cursor: pointer; }
.carousel-dot::before { content: ""; width: 8px; height: 8px; border-radius: var(--ux-pill); background: var(--ux-line); transition: width 150ms var(--ux-ease), height 150ms var(--ux-ease), background-color 150ms var(--ux-ease); }
.carousel-dot[aria-current="true"]::before { width: 20px; background: var(--ux-ink); }
.carousel.is-scrubbing .carousel-dot::before { height: 10px; }
.carousel-dot:focus-visible { outline: 3px solid var(--ux-focus); outline-offset: -8px; border-radius: var(--ux-pill); }

/* ---------- Booking: inline first step ---------- */
.bk-embed { background: var(--ux-paper); border-radius: var(--ux-radius-lg); padding: clamp(24px, 3.5vw, 40px); color: var(--ux-text); }
.on-dark .bk-embed { box-shadow: var(--ux-lift); }
.bk-embed.form--fog { background: var(--ux-muted); }
.bk-embed h2, .bk-embed h3 { color: var(--ux-heading); font-size: clamp(21px, 2.2vw, 28px); margin-bottom: 4px; }
.bk-embed .bk-q { font-weight: 600; color: var(--ux-ink); margin: 0 0 12px; }
.bk-embed .form-note { margin-top: 16px; }
.on-dark .bk-embed .form-note a { color: var(--ux-focus); }

/* ---------- Booking: answer tiles ---------- */
.bk-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.bk-opt {
  min-height: 52px; padding: 12px 16px; text-align: left;
  border: 1px solid var(--ux-line); border-radius: var(--ux-radius); background: var(--ux-paper);
  font: 600 16px/1.25 var(--ux-font); color: var(--ux-heading); cursor: pointer;
  transition: border-color 150ms var(--ux-ease), background-color 150ms var(--ux-ease);
}
.bk-opt:hover { border-color: var(--ux-ink); background: var(--ux-tint); }
.bk-opt[aria-pressed="true"] { border-color: var(--ux-ink); background: var(--ux-tint); box-shadow: inset 0 0 0 1px var(--ux-ink); }
.bk-opt:focus-visible { outline: 3px solid var(--ux-focus); outline-offset: 1px; }
@media (max-width: 340px) { .bk-opts { grid-template-columns: 1fr; } }
@media (max-width: 520px) { .bk-opt { min-height: 48px; padding: 10px 12px; font-size: 15px; } }

/* ---------- Booking: full-page experience ---------- */
.bk-lock, .bk-lock body { overflow: hidden; }
.bk { position: fixed; inset: 0; z-index: 100; background: var(--ux-paper); overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; }
.bk[hidden] { display: none; }
.bk-top { position: sticky; top: 0; z-index: 2; background: var(--ux-paper); }
.bk-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; max-width: 720px; width: 100%; margin: 0 auto; padding: 12px var(--ux-gutter); }
.bk-count { font-size: 15px; font-weight: 600; color: var(--ux-text); }
.bk-icon { width: 44px; height: 44px; border-radius: 50%; border: 1px solid rgb(14 15 12 / .12); background: var(--ux-paper); color: var(--ux-ink); display: grid; place-items: center; cursor: pointer; font-size: 26px; line-height: 1; }
.bk-icon:hover { background: var(--ux-tint); }
.bk-icon[hidden] { visibility: hidden; display: grid; }
.bk-back svg { width: 18px; height: 18px; transform: rotate(180deg); }
.bk-progress { height: 4px; background: var(--ux-muted); }
.bk-progress span { display: block; height: 100%; width: 4%; background: var(--ux-ink); border-radius: 0 var(--ux-pill) var(--ux-pill) 0; transition: width 300ms var(--ux-ease); }
.bk-form { flex: 1; width: 100%; max-width: 720px; margin: 0 auto; padding: clamp(28px, 6vh, 64px) var(--ux-gutter) 40px; }
.bk-step { display: grid; gap: 16px; }
.bk-step[hidden] { display: none; }
.bk-step h2 { font-size: clamp(32px, 5vw, 40px); color: var(--ux-heading); margin: 0; outline: none; }
.bk-sub { margin: -4px 0 4px; color: var(--ux-text); }
.bk-step .btn { justify-self: start; min-width: 200px; }
.bk-step .btn[hidden] { display: none; }
.bk-warn { padding: 16px 20px; border-radius: var(--ux-radius); background: #fdecea; border-left: 4px solid var(--ux-alarm); color: var(--ux-heading); }
.bk-warn[hidden] { display: none; }
.bk-warn a { color: var(--ux-alarm); font-weight: 700; }
.bk-error { padding: 16px; border-radius: var(--ux-radius); background: #fdecea; color: var(--ux-alarm); font-weight: 600; margin: 0; }
.bk-error[hidden] { display: none; }
.bk-hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.bk-addr { position: relative; }
.bk-suggest { position: absolute; z-index: 3; top: 100%; left: 0; right: 0; margin: 4px 0 0; padding: 4px; list-style: none; background: var(--ux-paper); border: 1px solid var(--ux-line); border-radius: var(--ux-radius); box-shadow: 0 6px 20px rgb(0 0 0 / .08); }
.bk-suggest[hidden] { display: none; }
.bk-suggest li { padding: 12px; border-radius: 8px; cursor: pointer; }
.bk-suggest li:hover, .bk-suggest li[aria-selected="true"] { background: var(--ux-tint); }
.bk-foot { border-top: 1px solid var(--ux-muted); background: var(--ux-muted); }
.bk-foot > div { max-width: 720px; margin: 0 auto; padding: 16px var(--ux-gutter) calc(16px + env(safe-area-inset-bottom)); }

/* ---------- Call status (Travis + posted hours) ---------- */
.call-status { display: flex; align-items: center; gap: 12px 16px; flex-wrap: wrap; }
.call-status img { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; flex: none; box-shadow: 0 0 0 2px var(--ux-paper); }
.call-text { display: grid; gap: 2px; font-size: 15px; line-height: 1.3; flex: 1; min-width: 180px; }
.call-text b { color: var(--ux-ink); }
.call-state { display: flex; align-items: center; gap: 8px; color: var(--ux-text); flex-wrap: wrap; }
.call-state i { width: 8px; height: 8px; border-radius: 50%; background: var(--ux-line); flex: none; }
.is-open .call-state i { background: #2fa84f; box-shadow: 0 0 0 3px rgb(47 168 79 / .2); }
.call-status .call-btn { min-height: 44px; padding: 10px 18px; }
.on-dark-status .call-text b { color: var(--ux-paper); }
.on-dark-status .call-state { color: var(--ux-on-dark); }
.on-dark-status img { box-shadow: 0 0 0 2px var(--ux-accent); }
.on-dark-status.is-closed .call-btn { background: transparent; border-color: var(--ux-paper); --sweep: rgb(255 255 255 / .22); }

/* ---------- First form step in the hero ---------- */
.hero-book { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--ux-rule-on-dark); }
.hero-book .bk-q { margin: 0 0 12px; font-weight: 600; color: var(--ux-paper); font-size: 15px; }
.hero-book .bk-opts { display: flex; flex-wrap: wrap; gap: 8px; }
.hero-book .bk-opt {
  min-height: 44px; padding: 10px 18px; border-radius: var(--ux-pill);
  background: transparent; color: var(--ux-paper); border: 1px solid rgb(255 255 255 / .55);
  font-size: 15px;
}
.hero-book .bk-opt:hover { background: rgb(255 255 255 / .12); border-color: var(--ux-paper); color: var(--ux-paper); }
.page-hero--split .bk-embed { box-shadow: var(--ux-lift); }
.info-cards--wide { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.info-cards--wide .map { grid-column: 1 / -1; }
.bk-embed .form-note, .on-dark .bk-embed .form-note { color: var(--ux-text); }
.on-dark .bk-embed .bk-q { color: var(--ux-ink); }

/* Multi-select answers: a check box shows what's picked. */
.bk-opts--multi .bk-opt { display: flex; align-items: center; gap: 12px; }
.bk-opts--multi .bk-opt::before {
  content: ""; flex: none; width: 20px; height: 20px; border-radius: 6px;
  border: 1.5px solid var(--ux-line); background: var(--ux-paper) center / 14px no-repeat;
}
.bk-opts--multi .bk-opt[aria-pressed="true"]::before {
  border-color: var(--ux-ink);
  background-color: var(--ux-ink);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 8.5l3.2 3L13 4.5' fill='none' stroke='%23fff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.bk-step .btn:disabled { background: var(--ux-muted); color: var(--ux-line); box-shadow: none; }
