/* Apex MD — house stylesheet.
   Hand-authored. Tokens mirror _build/style.py; keep the two in step.
   Per-page rules are generated into assets/css/<page>.css by _build/cssx.py.

   Every token is prefixed --apex-. That is not decoration: the handoffs
   declare their own :root blocks, which load after this file and win. The
   Concierge page sets `--ink: #FFFFFF` — the same name this file used for
   near-black — and silently turned the shared nav white on white. Prefixing
   means no page's palette can ever reach into the chrome again. */

:root {
  --apex-red:        #d30704;
  --apex-red-dark:   #a80503;
  --apex-red-bright: #ff5a4d;
  --apex-red-tint:   #fdeeee;
  --apex-pink:       #c2185b;   /* scoped: Women's Optimal Health */
  --apex-pink-dark:  #971146;

  --apex-ink:        #17140f;
  --apex-body:       #5f5952;
  --apex-muted:      #7d766c;
  --apex-ink-soft:   #33302b;
  --apex-bg:         #ffffff;
  --apex-bg-alt:     #faf8f6;
  --apex-rule:       #e4dfd9;

  --apex-font-ui:    Archivo, 'Helvetica Neue', Arial, sans-serif;
  --apex-font-mono:  'JetBrains Mono', ui-monospace, monospace;
  --apex-font-serif: 'Playfair Display', Georgia, serif;

  --apex-max:        1400px;
  --apex-gutter:     clamp(20px, 3.4vw, 48px);
  --apex-radius:     14px;
  --apex-header-h:   76px;
}

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--apex-bg);
  color: var(--apex-ink);
  font-family: var(--apex-font-ui);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;          /* desktop comps bleed decorative art off-canvas */
}

a { color: var(--apex-red); text-decoration: none; }
a:hover { color: var(--apex-red-dark); }
h1, h2, h3, h4 { line-height: 1.03; letter-spacing: -0.02em; }
/* height:auto is load-bearing. optimize.py stamps each image's intrinsic
   width/height so the browser can reserve space before it loads — but where
   a handoff sizes an image by width alone, the height attribute then wins
   and squashes it (Dr. Bowen's portrait drew 459px wide at the file's full
   918px height). height:auto keeps the reservation, from the attributes'
   ratio, without letting them dictate size. Any class that sets a height
   still wins over this, which is what the object-fit images rely on. */
img { max-width: 100%; height: auto; }

/* An image the design deliberately bleeds past its card (the dark texture in
   Women's "Optimization Membership"). Tagged by build.py's MOBILE_FIX. */
img.img-bleed { max-width: none; }
::selection { background: var(--apex-red); color: #fff; }

:focus-visible { outline: 3px solid var(--apex-red); outline-offset: 2px; }

/* Visible to assistive tech and search engines, not on screen. Used where a
   page's headline exists only inside a baked hero image. */
.vh {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  clip: rect(0 0 0 0); clip-path: inset(50%);
  overflow: hidden; white-space: nowrap;
}

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 200;
  background: var(--apex-ink); color: #fff; padding: 12px 18px;
  font: 600 14px/1 var(--apex-font-ui);
}
.skip:focus { left: 0; color: #fff; }

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

/* --------------------------------------------- unfilled image placeholder

   The Men's Optimal Health and Weight Loss handoffs left <image-slot>
   elements where an image was intended but never supplied. build.py turns
   each into one of these, captioned with its intended subject, so a missing
   image reads as unfinished rather than as an empty gap nobody notices.
   When the real image lands, replace the element with an <img>. */

.img-todo {
  display: flex; align-items: center; justify-content: center;
  min-height: 120px; padding: 16px;
  border: 2px dashed var(--apex-red);
  background: var(--apex-red-tint);
}
.img-todo::after {
  content: 'image needed: ' attr(data-todo);
  font: 600 12px/1.4 var(--apex-font-mono);
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--apex-red); text-align: center;
}

/* ------------------------------------------------------------ buttons */

.btn {
  display: inline-block;
  font: 900 13px/1 var(--apex-font-ui);
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 14px 24px;
  white-space: nowrap;
  transition: background .15s ease;
}
.btn-red { background: var(--apex-red); color: #fff; }
.btn-red:hover { background: var(--apex-red-dark); color: #fff; }

/* ------------------------------------------------------------- header */

.hdr {
  position: sticky; top: 0; z-index: 60;
  display: flex; align-items: center; justify-content: space-between;
  gap: clamp(16px, 2.4vw, 40px);
  height: var(--apex-header-h);
  padding: 0 var(--apex-gutter);
  background: var(--apex-bg);
  border-bottom: 2px solid var(--apex-rule);
}

.hdr-logo { display: flex; align-items: center; flex: none; }

/* The real lockup, shipped at 3x (499x102) and drawn at 34px tall. The
   intrinsic width/height attributes are on the tag so the header does not
   reflow as it loads. */
.brand-logo { display: block; height: 34px; width: auto; }
.brand-logo-ftr { height: 40px; }

.hdr-nav {
  display: flex; align-items: center; min-width: 0;
  gap: clamp(9px, 1.5vw, 26px);
  font: 900 clamp(10.5px, 1.02vw, 13px)/1 var(--apex-font-ui);
  letter-spacing: .02em; text-transform: uppercase;
  white-space: nowrap;
}
.hdr-nav > a, .hdr-drop-btn { color: var(--apex-ink); }
.hdr-nav > a:hover, .hdr-drop-btn:hover { color: var(--apex-red); }

/* the active section, stamped per page by build.py */
.hdr-nav [data-nav].is-active {
  color: var(--apex-red);
  padding-bottom: 3px;
  border-bottom: 2px solid var(--apex-red);
}

.hdr-drop { position: relative; }
.hdr-drop-btn {
  display: flex; align-items: center; gap: 6px;
  background: none; border: 0; cursor: pointer;
  font: inherit; color: var(--apex-ink);
  text-transform: inherit; letter-spacing: inherit;
}
.hdr-caret { width: 9px; height: 6px; transition: transform .18s ease; }
.hdr-drop-btn[aria-expanded="true"] .hdr-caret { transform: rotate(180deg); }

.hdr-menu {
  position: absolute; top: calc(100% + 14px); left: 50%;
  transform: translate(-50%, -6px);
  display: flex; flex-direction: column; gap: 2px;
  min-width: 232px; padding: 12px;
  background: #fff;
  border: 1px solid var(--apex-rule);
  box-shadow: 0 18px 46px rgba(0, 0, 0, .14);
  opacity: 0; visibility: hidden;
  transition: opacity .18s ease, transform .18s ease, visibility .18s;
}
.hdr-drop:hover .hdr-menu,
.hdr-drop:focus-within .hdr-menu,
.hdr-drop-btn[aria-expanded="true"] + .hdr-menu {
  opacity: 1; visibility: visible; transform: translate(-50%, 0);
}
.hdr-menu a {
  padding: 9px 12px;
  font: 600 14px/1.2 var(--apex-font-ui);
  letter-spacing: 0; text-transform: none;
  color: var(--apex-ink-soft);
}
.hdr-menu a:hover { background: var(--apex-red-tint); color: var(--apex-red); }

.hdr-end { display: flex; align-items: center; gap: 18px; flex: none; }
.hdr-login {
  font: 900 12px/1 var(--apex-font-ui);
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--apex-ink);
}
.hdr-login:hover { color: var(--apex-red); }

.hdr-burger {
  display: none;
  flex-direction: column; gap: 5px;
  background: none; border: 0; cursor: pointer;
  padding: 8px 4px;
}
.hdr-burger span { display: block; width: 24px; height: 2px; background: var(--apex-ink); }

/* ------------------------------------------------------- mobile drawer */

.drawer {
  position: fixed; inset: 0; z-index: 90;
  display: flex; flex-direction: column;
  padding: 0 var(--apex-gutter) 32px;
  background: var(--apex-bg);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.drawer[hidden] { display: none; }

.drawer-top {
  display: flex; align-items: center; justify-content: space-between;
  height: var(--apex-header-h);
  border-bottom: 2px solid var(--apex-rule);
  margin-bottom: 8px;
}
.drawer-x {
  background: none; border: 0; cursor: pointer;
  font-size: 34px; line-height: 1; color: var(--apex-ink);
  padding: 0 4px;
}

.drawer-nav { display: flex; flex-direction: column; }
.drawer-nav > a, .drawer-nav summary {
  display: block; padding: 15px 0;
  border-bottom: 1px solid var(--apex-rule);
  font: 800 16px/1.2 var(--apex-font-ui);
  color: var(--apex-ink);
  cursor: pointer;
}
.drawer-nav summary { list-style: none; }
.drawer-nav summary::-webkit-details-marker { display: none; }
.drawer-nav summary::after { content: ' +'; color: var(--apex-red); }
.drawer-nav details[open] summary::after { content: ' –'; }
.drawer-nav details a {
  display: block; padding: 12px 0 12px 16px;
  font: 500 15px/1.2 var(--apex-font-ui);
  color: var(--apex-body);
  border-bottom: 1px solid var(--apex-rule);
}
.drawer-cta { margin-top: 24px; text-align: center; padding: 17px 24px; }

body.nav-open { overflow: hidden; }

/* ------------------------------------------------------------- footer */

.ftr { background: var(--apex-bg); padding: 72px var(--apex-gutter) 40px; }

.ftr-grid {
  max-width: var(--apex-max); margin: 0 auto;
  display: grid; grid-template-columns: 1.2fr 1fr 1fr 1fr; gap: 48px;
  padding-bottom: 56px;
  border-bottom: 2px solid var(--apex-rule);
}
.ftr-brand { display: flex; flex-direction: column; gap: 16px; align-items: flex-start; }
.ftr-tag { font-size: 15px; color: var(--apex-muted); }

.ftr-col { display: flex; flex-direction: column; gap: 11px; }
.ftr-head {
  margin-bottom: 4px;
  font: 800 12px/1 var(--apex-font-mono);
  letter-spacing: .16em; text-transform: uppercase;
  color: var(--apex-muted);
}
.ftr-col a { font-size: 15px; color: var(--apex-ink-soft); }
.ftr-col a:hover { color: var(--apex-red); }

.ftr-base {
  max-width: var(--apex-max); margin: 0 auto; padding-top: 28px;
  display: flex; justify-content: space-between; align-items: center;
  gap: 32px; flex-wrap: wrap;
}
.ftr-trust {
  display: flex; gap: 22px; flex-wrap: wrap;
  font: 800 11px/1.4 var(--apex-font-mono);
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--apex-muted);
}
.ftr-legal { display: flex; gap: 22px; flex-wrap: wrap; font-size: 13px; color: var(--apex-muted); }
.ftr-legal a { color: var(--apex-muted); }

/* a pinned product bar would otherwise sit over the legal line for good */
body:has(.sticky-cta) .ftr { padding-bottom: 124px; }
.ftr-legal a:hover { color: var(--apex-red); }

/* -------------------------------------------------------- breakpoints */

/* The full nav (7 items + Patient Login + Get Started) needs ~1,210px. Measured
   2026-09-18: it overlapped the CTA from 1,200px down to 1,025px, and again from
   ~980px to 761px, because the menu button only arrived at 760px. Below 1,220px
   the inline nav gives way to the menu button (whose drawer carries every link
   and Patient Login); Get Started stays in the bar until phone width. */
@media (max-width: 1220px) {
  .hdr .hdr-nav, .hdr .hdr-login { display: none; }
  .hdr-burger { display: flex; }
}

@media (max-width: 1024px) {
  .hdr-login { display: none; }
  .ftr-grid { grid-template-columns: 1fr 1fr; gap: 40px; }
}

@media (max-width: 760px) {
  :root { --apex-header-h: 64px; }

  /* scoped to .hdr so a page's own .btn rules, which load later, cannot
     bring the desktop CTA back into the phone header (Concierge did) */
  .hdr .hdr-nav, .hdr .hdr-cta { display: none; }
  .hdr-burger { display: flex; }

  /* Men's and Women's pin a product bar to the bottom of the screen; at this
     width its title and price wrap it to 164px. Keep only the button. The
     body prefix outranks the page's generated class on the same element. */
  /* Named per-section fixes, tagged by MOBILE_FIX in build.py: side panels
     and feature images that are absolutely positioned against a desktop-width
     parent, and would otherwise land on top of the text. */
  body .m-hide { display: none; }
  body .m-autoheight { height: auto; }
  body .m-panel {
    position: relative; inset: auto;
    height: 260px; margin: 24px 20px 0;
  }
  body .m-static {
    position: relative; inset: auto; transform: none;
    width: 100%; max-width: 100%; height: auto; margin: 20px 0 0;
  }
  body .m-pad-top-48 { padding-top: 48px; }

  /* GLP-1's testimonial carousel sizes its cards for three across a desktop
     row; on a phone that leaves ~80px columns of one word per line. Show
     one card and the edge of the next, so the swipe is self-evident. */
  body [data-carousel-track] > * { flex: 0 0 78%; min-width: 0; max-width: none; }
  /* its arrows sit just outside the track on desktop — off-screen here */
  body [data-carousel-prev] { left: 6px; right: auto; }
  body [data-carousel-next] { right: 6px; left: auto; }

  body .sticky-cta { padding: 10px 14px; gap: 0; }
  body .sticky-cta > :not(a) { display: none; }
  body .sticky-cta > a { flex: 1; text-align: center; padding: 15px 16px; }
  body:has(.sticky-cta) .ftr { padding-bottom: 104px; }
  .brand-logo { height: 28px; }
  .brand-logo-ftr { height: 34px; }

  .ftr { padding: 44px var(--apex-gutter) 32px; }
  .ftr-grid { grid-template-columns: 1fr; gap: 32px; padding-bottom: 32px; }
  .ftr-base { padding-top: 22px; gap: 18px; }
  .ftr-legal { gap: 14px; font-size: 12px; }
}
