/* Hyper Endurance Fitness | phone and tablet polish layer
   ====================================================================
   Loaded last on every page, right after desktop.css. Every rule sits
   inside a max-width media query, so laptops and desktops are untouched
   (their layer is /assets/desktop.css, min-width rules only).
   ==================================================================== */

/* ---------------------------------------------------------------------
   Home hero: what every membership includes (ul.hx-deliver)
   Four chips, label at most 16 characters, uppercase via CSS.
   Tablet: one centred row (the old 600px cap forced a second row).
   Phone: a balanced 2 x 2 grid of equal width chips, the same width as
   the call to action buttons below it, so no chip is ever left alone on
   a row and the left and right edges line up with the buttons.
   --------------------------------------------------------------------- */
@media (min-width: 701px) and (max-width: 1023px) {
  .hx-deliver { max-width: none; gap: 8px; }
  .hx-deliver li { font-size: 11.5px; letter-spacing: 0.08em; padding: 9px 14px; }
}
@media (min-width: 701px) and (max-width: 819.98px) {
  /* landscape phones: four 16 character labels still fit on one row */
  .hx-deliver li { font-size: 10.5px; letter-spacing: 0.06em; padding: 9px 12px; }
}
@media (max-width: 700px) {
  .hx-deliver {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
    max-width: 360px;           /* same cap as .btn.hx-cta on phones */
    margin-left: auto;
    margin-right: auto;
  }
  .hx-deliver li {
    min-width: 0;
    text-align: center;
    padding: 9px 8px;
    font-size: 10.5px;
    letter-spacing: 0.06em;
  }
}

/* Home hero buttons on phones. They were sized by their longest label
   (308px at every phone width) while the other full width buttons on the
   page fill the column. They now fill the column up to the same 360px cap,
   matching the chip grid above them edge for edge. */
@media (max-width: 700px) {
  .hx-hero .hx-ctas { align-self: stretch; width: 100%; }
}

/* ---------------------------------------------------------------------
   Floating controls on the first screen of a phone.
   The English language pill (bottom left) and the Hyper Intelligence
   launcher (bottom right) are fixed to the bottom corners, which on a
   phone is exactly where the hero's primary button lands: at 390 x 844
   both sat on top of "Choose your membership". They now wait until the
   page has been scrolled a little (fully hidden for the first 60px, faded
   in by 130px), so the first screen is clean and they are there as soon
   as you move. The chat launcher already held back for the same reason,
   but only for 1.6 seconds. The same rule is in desktop.css from 1024px,
   where the launcher sat on headings at 1280 x 800 (Build Around You,
   The Endurance Method).
   Scroll driven animation: where a browser does not support it, nothing
   changes. On a page too short to scroll 130px (404, enquiry received on a
   big screen) they are fully in at the bottom of the page. Never applied while the chat panel is open (html.hi-open).
   --------------------------------------------------------------------- */
@media (max-width: 1023.98px) {
  @keyframes lx-float-in {
    0%, 46% { opacity: 0; visibility: hidden; }
    100%    { opacity: 1; visibility: visible; }
  }
  @supports (animation-timeline: scroll()) {
    html:not(.hi-open) .hef-lang,
    html:not(.hi-open) #hyper-intelligence {
      animation: lx-float-in linear both;
      animation-timeline: scroll(root block);
      animation-range: 0px min(130px, 100%);
    }
    /* the animated host becomes a stacking context: keep it on top, just
       under the language pill, as the launcher itself already is */
    #hyper-intelligence { position: relative; z-index: 2147483000; }
  }
}

/* Home hero headline on the narrowest phones (360px): "you know you can
   be" needed 324px and had 316px, so the gold clause broke over two lines
   and the headline ran to three. A step down in size keeps it on two. */
@media (max-width: 374px) {
  .hero-h1.hx-h1 { font-size: 32.5px; }
}

/* ---------------------------------------------------------------------
   Line breaking, every page (the same two rules sit in desktop.css for
   1024px and up).
   Headings: balanced lines, so no heading strands a single word on its
   last line ("MILLIONS", "EITHER", "YOU", "commit" on phones).
   Text: pretty wrapping, so a paragraph or list item does not end on one
   short orphan word. Longhands only, so nothing that is deliberately set
   to nowrap is touched; browsers without support simply wrap as before.
   --------------------------------------------------------------------- */
@media (max-width: 1023.98px) {
  h1, h2, h3, h4, .sec-h2, .hero-h1, .p-h1, .chapter-label { text-wrap-style: balance; }
  body, p, li, dd, blockquote, figcaption, summary { text-wrap-style: pretty; }
}

/* ---------------------------------------------------------------------
   Closing call to action (section.apply on Home, About, Method, Build
   Around You, Testimonials).
   Phones: the two buttons were each sized by their own label (241px and
   219px on About), so they sat as two different widths under each other,
   while the single button higher up the page fills the column. They now
   stack at one shared width, the column up to 360px, like the hero.
   Phones and tablets: the short lead under the centred heading is centred
   too (Home set it left, the other pages centred it).
   --------------------------------------------------------------------- */
@media (max-width: 1023.98px) {
  .apply .wrap.center .p-lead { text-align: center; }
}
@media (max-width: 700px) {
  .apply .wrap.center > div {
    flex-direction: column;
    align-items: stretch;
    gap: 12px !important;            /* the row gap is set inline */
    width: 100%;
    max-width: 360px;
    margin-left: auto;
    margin-right: auto;
  }
  .apply .wrap.center > div > .btn { justify-content: center; width: 100%; }
}
@media (max-width: 400px) {
  /* "See what membership includes" broke over two lines at 360px */
  .apply .wrap.center > div > .btn { padding-left: 16px; padding-right: 16px; }
}

/* Article call to action box (every article and the articles index):
   the two buttons wrapped to two rows at two different widths on phones.
   They now stack at the full width of the box. */
@media (max-width: 620px) {
  .cta-actions { flex-direction: column; align-items: stretch; }
  .cta-actions > .btn { text-align: center; }
}

/* Home "The system" lead: one short paragraph under a centred heading and
   above a centred grid, so it is centred too (it was set left). The same
   rule is in desktop.css from 1024px. */
@media (max-width: 1023.98px) {
  .approach .wrap.center .p-lead { text-align: center; }
  .approach-close { text-wrap-style: balance; }
}

/* The Endurance Method: TRAIN | FUEL | PROGRESS | BELONG wrapped below
   480px with BELONG alone on a second row behind a stray divider. Phones
   get a balanced 2 x 2 with the dividers down the middle only. */
@media (max-width: 480px) {
  .ps-standard .ps-quad {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    row-gap: 14px;
    max-width: 360px;
    margin-left: auto;
    margin-right: auto;
  }
  .ps-standard .ps-quad span:nth-child(odd)::before { display: none; }
}

/* Testimonials: two column card grid (861 to 1023px here, desktop.css
   above): cards in a row now share one height with the member line pinned
   to the foot, instead of ending 6 to 66px apart. */
@media (min-width: 861px) and (max-width: 1023.98px) {
  .fb-grid { align-items: stretch; }
  .fb-card > .fb-tags { margin-bottom: 20px; }
  .fb-card > .fb-who { margin-top: auto; }
}

/* ---------------------------------------------------------------------
   Tap targets on phones (44px, Apple HIG). Footer links, the footer
   email, back links, the header logo and menu button, and small text
   links were 30 to 42px tall. An invisible hit area is added around each
   one, so nothing moves on screen.
   --------------------------------------------------------------------- */
@media (max-width: 760px) {
  footer nav a, .footer-nav a, .foot-contact a, .footer-contact a,
  .back-link, .app-fuel__link, .nav .brand, .site-header .brand,
  .nav-toggle, .fb-more > summary, .bx-more > summary,
  .closer-contact a, .bar > a {
    position: relative;
  }
  footer nav a::before, .footer-nav a::before, .foot-contact a::before,
  .footer-contact a::before, .back-link::before, .app-fuel__link::before,
  .nav .brand::before, .site-header .brand::before, .nav-toggle::before,
  .fb-more > summary::before, .bx-more > summary::before,
  .closer-contact a::before, .bar > a::before {
    content: "";
    position: absolute;
    left: -4px;
    right: -4px;
    top: 50%;
    height: 44px;
    transform: translateY(-50%);
  }
  .nav-toggle::before { left: 0; right: 0; }
}

/* About, "Our approach": the body under the centred heading was set left
   while every other section of the page centres its text on phones. */
@media (max-width: 1023.98px) {
  .wrap > .center + .p-body { text-align: center; }
}

/* Testimonials at 360px: the first card's three tags left STRENGTH alone
   on a second row, and "Hyper Endurance Fitness Member" broke over two
   lines in every card. Slightly tighter tracking below 375px keeps both
   on one line. */
@media (max-width: 374px) {
  .fb-tags { gap: 5px; }
  .fb-tags span { letter-spacing: 0.12em; padding-left: 7px; padding-right: 7px; }
  .fb-card .fb-who b { letter-spacing: 0.08em; }   /* outranks .fb-av + div b in motion.css */
}

/* Pull quotes (Build Around You, Testimonials) balance their lines */
@media (max-width: 1023.98px) {
  q { text-wrap-style: balance; }
}

/* Articles: the category tag ("Nutrition") is plain gold text, but the
   phone type scale in motion.css gives every .tag chip padding, so on
   phones it sat 9px in from the title edge and off the date's baseline. */
@media (max-width: 760px) {
  .card-meta .tag { padding: 0; }
}

/* Article call to action heading inherited the 1.7 body line height, so a
   two line heading ("Put a coach / behind you") had a 44px gap between
   its lines. Same fix in desktop.css. */
@media (max-width: 1023.98px) {
  .article-cta h2 { line-height: 1.2; }
}

/* Articles: the head section ends on a hairline and the first chapter
   opened with another one 40 to 50px below it, a double rule. Where the
   first chapter follows the head directly, it drops its top rule (same in
   desktop.css). */
@media (max-width: 1023.98px) {
  .article-body > .shell > .chapter:first-child { border-top: 0; }
}

/* About, "Build the body" cards (.c-grid, three cards): the auto-fit grid
   went to two columns between about 520 and 775px, leaving Confidence
   alone on a second row. Three across on tablets, one column on phones. */
@media (min-width: 701px) and (max-width: 1023.98px) {
  .c-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .c-grid { grid-template-columns: minmax(0, 1fr); }
}

/* Footer links, centred footer (Home, About, Method, Build Around You,
   Testimonials): ten links wrapped 9 + 1 between about 780 and 1000px,
   leaving "Cookie settings" alone. Two even rows of five instead. */
@media (min-width: 761px) and (max-width: 1023.98px) {
  footer nav { display: grid; grid-template-columns: repeat(5, auto); justify-content: center; column-gap: 26px; row-gap: 14px; }
}
/* Footer links, left aligned footer (Membership, Articles, legal pages):
   the nine or ten links wrapped 2 + 3 + 3 + 1 on phones, 4 + 5 + 1 at
   540px and 8 + 1 or 9 + 1 from 820 to 1000px, always with Instagram alone
   on the last line. Two even columns on phones and small tablets, five
   aligned columns (two rows) on larger tablets. */
@media (max-width: 760px) {
  .footer-nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
}
@media (min-width: 761px) and (max-width: 1023.98px) {
  .footer-nav { display: grid; grid-template-columns: repeat(5, max-content); gap: 12px 28px; }
}

/* ==== SITE B: BEGIN ==== */
/* QA round 1 fixes (phones and tablets). Applied by team/siteb-patch.py. */

/* Home hero (QA M1): the pill and launcher faded in exactly as the hero
   buttons crossed the bottom of the screen. On the home page they now
   wait until the hero has scrolled away (one screen). */
@media (max-width: 1023.98px) {
  @supports (animation-timeline: scroll()) {
    html:has(.hx-hero):not(.hi-open) .hef-lang,
    html:has(.hx-hero):not(.hi-open) #hyper-intelligence { animation-range: 0px min(100svh, 100%); }
  }
}

/* About h1: balance reaches the gold clause only if it is its own block
   ("BELIEF" was alone at 768) (QA m06) */
@media (max-width: 1023.98px) {
  .p-h1 > span { display: block; }
}

/* The Endurance Method h1 left METHOD alone at 360 to 430 (QA m04) */
@media (max-width: 440px) {
  #top:has(.ps-index) .p-h1 { font-size: min(31px, calc((100vw - 48px) * 0.0775)); }   /* that page only */
}

/* Left aligned footer: "The Endurance Method" wrapped at 360 (QA m05) */
@media (max-width: 374px) {
  .footer-nav a { font-size: 13px; white-space: nowrap; }
}

/* Menu: Join was indented 10px more than the other links at 400px and
   below (QA m03); the open panel let the page show through (QA m02) */
@media (max-width: 400px) {
  .nav-links a.nav-join, .site-header .site-nav a.nav-join { padding-left: 22px; padding-right: 22px; }
}
@media (max-width: 1023.98px) {
  .nav.open .nav-links { background: #08090a; -webkit-backdrop-filter: none; backdrop-filter: none; }
}

/* Community Day CTA: the two stacked buttons were 52 and 76px tall (QA m08) */
@media (max-width: 400px) {
  .cta-actions > .btn { padding-left: 16px; padding-right: 16px; white-space: nowrap; }
}

/* Tap targets, measured boxes now 44px (QA m11). The header keeps its
   75px height: the bar padding gives back the 4px the button gains. */
@media (max-width: 1023.98px) {
  .nav-toggle { height: 44px; }
  .nav .wrap { padding-top: 15px; padding-bottom: 15px; }
}
@media (max-width: 1023.98px) {
  .hef-cc-x { width: 44px; height: 44px; }
  footer nav a, .footer-nav a { display: inline-flex; align-items: center; min-height: 44px; }
  footer nav, .footer-nav { row-gap: 0 !important; }
  .back-link, .app-fuel__link, .bx-more > summary, .fb-more > summary,
  .footer-contact a, .foot-contact a, .closer-contact a {
    display: inline-flex; align-items: center; min-height: 44px;
  }
  .skip-link { min-height: 44px; display: inline-flex; align-items: center; }
}
/* ==== SITE B: END ==== */

/* Menu open: the page behind it does not scroll (all header types) */
@media (max-width: 1023.98px) {
  html:has(.nav.open), html:has(.site-header.nav-open) { overflow: hidden; }
}

/* Language menu options: full touch target on touch screens */
@media (pointer: coarse) { .hef-lang-opt { min-height: 48px; } }

/* ==== SEO A5: BEGIN ==== */
/* Mobile friendliness and accessibility (SEO agent 5). Phones only.
   1. Cookie popup: on phones it opened as a centred card over a blurred,
      66% black page, so the page heading was hidden on first load. It now
      sits at the foot of the screen as a compact sheet over a light scrim,
      so the heading and opening lines stay readable above it. The three
      choices keep identical size, weight and colour. */
@media (max-width: 700px) {
  html body .hef-cc { align-items: flex-end; padding: 0 10px max(10px, env(safe-area-inset-bottom)); }
  html body .hef-cc-backdrop { background: rgba(0,0,0,0.38); backdrop-filter: none; -webkit-backdrop-filter: none; }
  html body .hef-cc-inner { padding: 18px 18px 16px; border-radius: 18px; max-height: 62vh; transform: translateY(14px); }
  html body .hef-cc.is-in .hef-cc-inner { transform: none; }
  html body .hef-cc-x { top: 10px; right: 8px; width: 44px; height: 44px; }
  html body .hef-cc-title { margin: 0 0 6px; }
  html body .hef-cc-body { font-size: 13px; line-height: 1.5; }
  html body .hef-cc-actions { grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
  html body .hef-cc-btn { padding: 0 8px; letter-spacing: 0.02em; font-size: 12.5px; }
}
@media (max-width: 380px) {
  html body .hef-cc-btn { font-size: 12px; letter-spacing: 0; }
}

/* 2. Legible text: body content on phones never drops below 12px
      (Google mobile friendliness, Lighthouse legible font sizes). Short
      uppercase labels (eyebrows, chapter labels, card numbers) keep their
      design size. */
@media (max-width: 700px) {
  html body header.hx-hero .hx-deliver li { font-size: 12px; letter-spacing: 0.04em; }
  /* motion.css sets these to 11px !important on phones; body content
     (price line, form labels, qualifications) gets 12px */
  html body header.hx-hero .hx-copy > .hx-trust, html body .hx-trust a,
  html body .f-quals li { font-size: 12px !important; }
  html body .hf-footer .hf-footer__legal, html body .hf-footer .hf-footer__legal p { font-size: 12px; }
  html body .lead-field label { font-size: 12px; }
}
/* ==== SEO A5: END ==== */
