/* ==========================================================================
   MotionMed – main stylesheet
   Tokens come from theme.json as --wp--preset--* custom properties.
   Sections: tokens · reset · typography · layout · buttons · top bar ·
   header/nav · page header · footer · core blocks · lightbox · utilities
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  --c-primary: var(--wp--preset--color--primary);
  --c-primary-dark: var(--wp--preset--color--primary-dark);
  --c-ink: var(--wp--preset--color--ink);
  --c-text: var(--wp--preset--color--text);
  --c-muted: var(--wp--preset--color--muted);
  --c-bg: var(--wp--preset--color--bg);
  --c-tint: var(--wp--preset--color--tint);
  --c-line: var(--wp--preset--color--line);
  --c-white: var(--wp--preset--color--white);

  --font-body: var(--wp--preset--font-family--body);
  --font-heading: var(--wp--preset--font-family--heading);

  --radius: 16px;
  --radius-lg: 24px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgb(31 53 80 / 0.06), 0 4px 12px rgb(31 53 80 / 0.05);
  --shadow-md: 0 2px 4px rgb(31 53 80 / 0.06), 0 12px 32px rgb(31 53 80 / 0.10);

  --gutter: var(--wp--preset--spacing--gutter);
  --wide: var(--wp--style--global--wide-size, 1240px);
  --content: var(--wp--style--global--content-size, 1100px);
  --header-h: 76px;
  --section-gap: clamp(3rem, 6vw, 5rem);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); }
html.nav-open { overflow: hidden; }

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-body);
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img,
svg,
video,
iframe { display: block; max-width: 100%; }
img { height: auto; }

a { color: var(--c-primary); text-decoration: none; transition: color 0.15s var(--ease); }
a:hover { color: var(--c-primary-dark); }

button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }

:focus-visible { outline: 3px solid var(--c-primary); outline-offset: 3px; border-radius: 4px; }

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

/* ---------- Typography ---------- */
h1, h2, h3, h4, h5, h6 {
  margin: 0 0 0.5em;
  font-family: var(--font-heading);
  font-weight: 600;
  line-height: 1.2;
  color: var(--c-ink);
  text-wrap: balance;
}
h1 { font-size: var(--wp--preset--font-size--hero); line-height: 1.1; }
h2 { font-size: var(--wp--preset--font-size--xxl); }
h3 { font-size: var(--wp--preset--font-size--xl); }
h4 { font-size: var(--wp--preset--font-size--lg); }

p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }

.eyebrow {
  display: block;
  margin-bottom: 0.75rem;
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--c-primary);
}
.lead { font-size: var(--wp--preset--font-size--lg); color: var(--c-muted); }

/* ---------- Layout ---------- */
.site-main { flex: 1 0 auto; }

.wrap {
  width: 100%;
  max-width: calc(var(--wide) + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.wrap--content { max-width: calc(var(--content) + 2 * var(--gutter)); }

/* Content area: core layout CSS centres blocks to contentSize; full-width
   blocks bleed to the viewport thanks to has-global-padding. */
.entry-content { padding-block: 0; }
.entry-content > :where(* + *) { margin-block-start: var(--wp--style--block-gap, 1.25rem); }
.entry-content > .alignfull + .alignfull { margin-block-start: 0; }

/* Vertical rhythm between big sections */
.section { padding-block: var(--wp--preset--spacing--xl); }
.section--tint { background: var(--c-tint); }
.section__title { text-align: left; margin-bottom: var(--wp--preset--spacing--md); }
.section__title--center { text-align: center; }

.card {
  background: var(--c-white);
  border: 1px solid var(--c-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

/* ---------- Buttons ---------- */
.btn,
.wp-block-button__link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 48px;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.2;
  text-decoration: none;
  border: 1.5px solid transparent;
  transition: background-color 0.15s var(--ease), color 0.15s var(--ease), border-color 0.15s var(--ease), transform 0.15s var(--ease);
}
.btn:active { transform: translateY(1px); }

.btn--primary,
.wp-block-button__link { background: var(--c-primary); color: var(--c-white); }
.btn--primary:hover,
.wp-block-button__link:hover { background: var(--c-primary-dark); color: var(--c-white); }

.btn--light { background: var(--c-white); color: var(--c-primary); }
.btn--light:hover { background: var(--c-tint); color: var(--c-primary-dark); }

.btn--ghost { background: transparent; color: var(--c-white); border-color: rgb(255 255 255 / 0.7); }
.btn--ghost:hover { background: rgb(255 255 255 / 0.12); color: var(--c-white); border-color: var(--c-white); }

.btn--outline { background: transparent; color: var(--c-primary); border-color: var(--c-primary); }
.btn--outline:hover { background: var(--c-primary); color: var(--c-white); }

.btn .icon { width: 18px; height: 18px; }

.link-arrow {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-weight: 600;
}
.link-arrow .icon { width: 18px; height: 18px; transition: transform 0.15s var(--ease); }
.link-arrow:hover .icon { transform: translateX(3px); }

/* ---------- Icons ---------- */
.icon { width: 1.25em; height: 1.25em; flex: none; }

/* ---------- Top bar ---------- */
.top-bar {
  background: var(--c-primary);
  color: var(--c-white);
  font-size: 0.8125rem;
}
.top-bar__inner {
  display: flex;
  justify-content: space-between;
  gap: 1rem 2rem;
  min-height: 36px;
  align-items: center;
}
.top-bar__group { display: flex; flex-wrap: wrap; gap: 0.25rem 1.5rem; }
.top-bar__item { display: inline-flex; align-items: center; gap: 0.4rem; color: inherit; opacity: 0.92; }
.top-bar__item:hover { color: inherit; opacity: 1; }
.top-bar__item .icon { width: 14px; height: 14px; }
.top-bar__item small { opacity: 0.75; font-size: inherit; }

@media (max-width: 767px) {
  .top-bar__item--hours { display: none; }
  .top-bar__item small { display: none; }
}
@media (max-width: 479px) {
  .top-bar__inner { justify-content: center; }
  .top-bar__group:last-child { display: none; }
}

/* ---------- Header / navigation ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgb(245 249 252 / 0.85);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.site-header.is-scrolled { border-color: var(--c-line); box-shadow: var(--shadow-sm); }

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  min-height: var(--header-h);
}

.site-logo { display: inline-flex; align-items: center; color: var(--c-ink); }
.site-logo__img { width: auto; height: 36px; }
.site-logo__text { font-family: var(--font-heading); font-size: 1.5rem; font-weight: 700; }

.site-nav { display: flex; align-items: center; gap: 1.5rem; }
.site-nav__list { display: flex; align-items: center; gap: 0.25rem; margin: 0; padding: 0; list-style: none; }
.site-nav__list a {
  display: inline-block;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-pill);
  color: var(--c-text);
  font-weight: 500;
}
.site-nav__list a:hover { color: var(--c-primary); background: var(--c-tint); }
.site-nav__list .current-menu-item > a,
.site-nav__list .current-menu-ancestor > a { color: var(--c-primary); font-weight: 600; }

.nav-toggle {
  display: none;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--c-ink);
}
.nav-toggle:hover { background: var(--c-tint); }
.nav-toggle .icon { width: 26px; height: 26px; }
.nav-toggle__close { display: none; }
.nav-toggle[aria-expanded="true"] .nav-toggle__open { display: none; }
.nav-toggle[aria-expanded="true"] .nav-toggle__close { display: block; }

@media (max-width: 1023px) {
  .nav-toggle { display: inline-flex; order: 3; }
  .site-nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: calc(100dvh - var(--header-h));
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 1rem var(--gutter) 2rem;
    background: var(--c-bg);
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.2s var(--ease), transform 0.2s var(--ease), visibility 0s linear 0.2s;
  }
  .site-nav.is-open { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
  .site-nav__list { flex-direction: column; align-items: stretch; gap: 0; }
  .site-nav__list a { display: block; padding: 0.875rem 0.5rem; font-size: 1.125rem; border-radius: 8px; }
  .site-nav__list li + li { border-top: 1px solid var(--c-line); }
  .site-nav__cta { margin-top: 1.5rem; }
}

/* ---------- Page header (fallback, no image) ---------- */
.page-header {
  background: var(--c-tint);
  padding-block: clamp(2.5rem, 6vw, 4.5rem);
  margin-bottom: var(--wp--preset--spacing--lg);
}
.page-header__title { margin: 0; }
.page-header__lead { margin: 0.75rem 0 0; max-width: 60ch; font-size: var(--wp--preset--font-size--lg); color: var(--c-muted); }

/* ---------- Footer ---------- */
.site-footer {
  margin-top: var(--wp--preset--spacing--xl);
  background: var(--c-tint);
  border-top: 1px solid var(--c-line);
  color: var(--c-text);
}
.site-footer__grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 2.5rem 3rem;
  padding-block: clamp(2.5rem, 6vw, 4rem) 2rem;
}
.site-footer__title { font-size: 1.125rem; margin-bottom: 1rem; }
.site-footer__tagline { max-width: 36ch; color: var(--c-muted); }
.site-footer__list { margin: 0; padding: 0; list-style: none; display: grid; gap: 0.5rem; }
.site-footer__list a { color: var(--c-text); }
.site-footer__list a:hover { color: var(--c-primary); }
.site-logo--footer .site-logo__img { height: 32px; }
.site-footer__social { display: flex; gap: 0.75rem; margin-top: 1rem; }
.site-footer__social a {
  display: inline-flex;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--c-white);
  color: var(--c-primary);
  box-shadow: var(--shadow-sm);
}
.site-footer__bottom {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  padding-block: 1.25rem;
  border-top: 1px solid var(--c-line);
  font-size: 0.875rem;
  color: var(--c-muted);
}

@media (max-width: 1023px) {
  .site-footer__grid { grid-template-columns: 1fr 1fr; }
  .site-footer__col--brand { grid-column: 1 / -1; }
}
@media (max-width: 599px) {
  .site-footer__grid { grid-template-columns: 1fr; }
}

/* ---------- Core blocks ---------- */
.entry-content ul:not([class]),
.entry-content ol:not([class]) { padding-left: 1.25rem; margin: 0 0 1em; }
.entry-content ul:not([class]) li,
.entry-content ol:not([class]) li { margin-bottom: 0.5rem; }
.entry-content ul:not([class]) { list-style: none; padding-left: 0; }
.entry-content ul:not([class]) > li { position: relative; padding-left: 1.5rem; }
.entry-content ul:not([class]) > li::before {
  content: "";
  position: absolute;
  left: 0.125rem;
  top: 0.65em;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--c-primary);
}

.entry-content .wp-block-image img,
.entry-content .wp-block-gallery img { border-radius: var(--radius); }

/* Galleries: uniform 4:3 grid, 4 → 3 → 2 columns, regardless of editor column setting */
.entry-content .wp-block-gallery.has-nested-images {
  display: grid !important;
  grid-template-columns: repeat(var(--gallery-cols, 4), 1fr);
  gap: 1rem !important;
  margin-block: var(--section-gap);
}
.entry-content .wp-block-gallery.has-nested-images figure.wp-block-image {
  width: auto !important;
  margin: 0 !important;
  display: block;
}
.entry-content .wp-block-gallery.has-nested-images figure.wp-block-image > a,
.entry-content .wp-block-gallery.has-nested-images figure.wp-block-image img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}
.entry-content .wp-block-gallery figcaption { display: none; }
@media (max-width: 1023px) { .entry-content .wp-block-gallery.has-nested-images { --gallery-cols: 3; } }
@media (max-width: 599px)  { .entry-content .wp-block-gallery.has-nested-images { --gallery-cols: 2; gap: 0.5rem !important; } }

.entry-content .wp-block-columns { gap: var(--wp--preset--spacing--md); }

.entry-content .wp-block-separator { border: 0; border-top: 1px solid var(--c-line); margin-block: var(--wp--preset--spacing--md); }

.entry-content .wp-block-table table { width: 100%; border-collapse: collapse; }
.entry-content .wp-block-table td,
.entry-content .wp-block-table th { padding: 0.625rem 0.75rem; border-bottom: 1px solid var(--c-line); text-align: left; }

.entry-content blockquote { margin: 0; padding-left: 1.25rem; border-left: 3px solid var(--c-primary); color: var(--c-muted); }

/* Contact Form 7 */
.wpcf7 form { display: grid; gap: 1rem; }
.wpcf7 label { display: block; font-weight: 600; font-size: 0.9375rem; color: var(--c-ink); }
.wpcf7 input:not([type="submit"]):not([type="checkbox"]):not([type="radio"]),
.wpcf7 textarea,
.wpcf7 select {
  display: block;
  width: 100%;
  margin-top: 0.375rem;
  padding: 0.75rem 1rem;
  font: inherit;
  color: var(--c-text);
  background: var(--c-white);
  border: 1px solid var(--c-line);
  border-radius: 12px;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.wpcf7 input:focus,
.wpcf7 textarea:focus,
.wpcf7 select:focus { outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 3px rgb(46 106 158 / 0.18); }
.wpcf7 textarea { min-height: 160px; resize: vertical; }
.wpcf7 input[type="submit"] {
  display: inline-flex;
  min-height: 48px;
  padding: 0.75rem 1.75rem;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--c-primary);
  color: var(--c-white);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.wpcf7 input[type="submit"]:hover { background: var(--c-primary-dark); }
.wpcf7 .wpcf7-not-valid-tip { color: #b42318; font-size: 0.875rem; margin-top: 0.25rem; }
.wpcf7 .wpcf7-response-output { margin: 0; padding: 0.875rem 1rem; border-radius: 12px; border: 1px solid var(--c-line); background: var(--c-white); }
.wpcf7 .wpcf7-spinner { display: none; }

/* ---------- Lightbox (native <dialog>) ---------- */
.lightbox {
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgb(16 36 43 / 0.92);
  color: var(--c-white);
}
.lightbox::backdrop { background: transparent; }
.lightbox__figure { margin: 0; width: 100%; height: 100%; display: grid; place-items: center; padding: clamp(1rem, 5vw, 4rem); }
.lightbox__img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; border-radius: 8px; }
.lightbox button {
  position: absolute;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgb(255 255 255 / 0.12);
  color: var(--c-white);
  font-size: 2rem;
  line-height: 1;
}
.lightbox button:hover { background: rgb(255 255 255 / 0.24); }
.lightbox__close { top: 1rem; right: 1rem; }
.lightbox__prev { left: 1rem; top: 50%; translate: 0 -50%; }
.lightbox__next { right: 1rem; top: 50%; translate: 0 -50%; }

/* ---------- Click-to-load embed ---------- */
.embed-box {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--c-tint);
  aspect-ratio: 4 / 3;
}
.embed-box iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.embed-box__cta {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 0.75rem;
  text-align: center;
  padding: 1.5rem;
  color: var(--c-muted);
  font-size: 0.9375rem;
}
.embed-box.is-loaded .embed-box__cta { display: none; }

/* ---------- Utilities ---------- */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.skip-link:focus {
  position: fixed !important;
  top: 8px;
  left: 8px;
  z-index: 100;
  width: auto;
  height: auto;
  margin: 0;
  padding: 0.75rem 1rem;
  clip: auto;
  clip-path: none;
  background: var(--c-white);
  color: var(--c-ink);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
}

.post-list { padding-left: 1.25rem; }

/* Editor canvas: give the body our background so block previews match. */
.editor-styles-wrapper { background: var(--c-bg); }

/* Editor-only placeholder for empty ACF blocks */
.mm-block-placeholder {
  padding: 1.5rem;
  border: 1px dashed var(--c-line);
  border-radius: var(--radius);
  background: var(--c-tint);
  color: var(--c-muted);
  text-align: center;
  font-size: 0.9375rem;
}
