/* ============================================================
   05-services — bento grid, bone section.
   Scoped under .sec-05-services. See section contract in
   docs/superpowers/specs/2026-07-13-modern-momentum-home-design.md
   ============================================================ */

.sec-05-services {
  background: radial-gradient(120% 85% at 50% 0%, #fbf9f3 0%, var(--bone) 50%, #eee8db 100%);
}

/* Rebalanced for 11 services (master ships 5). 12 columns x 5 rows:
   rows 1-2 tall for the flagship feature tile, rows 3-4 a pair of thirds,
   row 5 a full-width banner. See the placement block below. */
.sec-05-services__grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-template-rows:
    clamp(260px, 22vw, 340px)
    clamp(260px, 22vw, 340px)
    clamp(210px, 17vw, 270px)
    clamp(210px, 17vw, 270px)
    clamp(190px, 15vw, 240px);
  gap: var(--sp-gap);
}

.sec-05-services__tile {
  position: relative;
  display: block;
  grid-column: 1 / 13;
  border-radius: var(--radius-card);
  overflow: hidden;
  isolation: isolate;
  text-decoration: none;
  color: var(--white);
  box-shadow: var(--shadow-soft);
  transition: transform 420ms var(--ease-out), box-shadow 420ms var(--ease-out);
}

.sec-05-services__tile:hover,
.sec-05-services__tile:focus-visible {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lift);
}

.sec-05-services__photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(0.85) contrast(1.05) brightness(0.85);
  transform: scale(1.02);
  transition: filter 600ms var(--ease-out), transform 900ms var(--ease-out);
}

.sec-05-services__tile::before {
  content: "";
  position: absolute;
  inset: 0;
  background: hsl(var(--accent-h) 70% 30% / 0.5);
  mix-blend-mode: color;
  z-index: 1;
  transition: opacity 500ms var(--ease-out);
}

.sec-05-services__tile:hover .sec-05-services__photo,
.sec-05-services__tile:focus-visible .sec-05-services__photo {
  filter: grayscale(0) contrast(1) brightness(0.92);
  transform: scale(1.08);
}

.sec-05-services__tile:hover::before,
.sec-05-services__tile:focus-visible::before {
  opacity: 0;
}

.sec-05-services__scrim {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(to top, hsl(200 30% 6% / 0.88) 0%, hsl(200 30% 6% / 0.25) 55%, transparent 85%);
}

.sec-05-services__body {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  height: 100%;
  padding: 1.5rem 1.6rem;
  justify-content: flex-end;
}

.sec-05-services__title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-h4);
  letter-spacing: -0.01em;
}

.sec-05-services__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.sec-05-services__tag {
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.2;
  color: hsl(0 0% 100% / 0.92);
  background: hsl(0 0% 100% / 0.16);
  border: 1px solid hsl(0 0% 100% / 0.32);
  border-radius: var(--radius-pill);
  padding: 0.28rem 0.7rem;
  white-space: nowrap;
  backdrop-filter: blur(6px);
}

.sec-05-services__desc {
  font-size: 0.92rem;
  line-height: 1.45;
  color: hsl(0 0% 100% / 0.82);
  max-width: 34ch;
}

.sec-05-services__arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  margin-top: 0.35rem;
  border-radius: var(--radius-pill);
  background: hsl(0 0% 100% / 0.14);
  border: 1px solid hsl(0 0% 100% / 0.28);
  font-size: 1rem;
  transition: transform 350ms var(--ease-spring), background-color 300ms var(--ease-out);
}

.sec-05-services__tile:hover .sec-05-services__arrow,
.sec-05-services__tile:focus-visible .sec-05-services__arrow {
  transform: translateX(6px);
  background: var(--accent);
}

/* --- Bento placement (desktop) ---
   11 tiles. --spine-lab is the flagship and keeps the tall feature tile.
   --manual is the small tile and carries the compact body treatment.
   --emg is the full-width banner and carries the horizontal body treatment. */
@media (min-width: 861px) {
  /* QA fix (round 3): the pelvic/manual row was a 3:2 split of a 5-column
     zone (8/11 + 11/13) -- manual came out ~173px wide at the 1200px
     container width, visibly cramped next to pelvic's ~276px regardless of
     its own copy length. Widened the whole right-hand zone from 5 to 6
     columns (spine-lab gives up one column, 1/8 -> 1/7; pt grows to match,
     8/13 -> 7/13) so pelvic and manual can split it evenly, 3+3, instead of
     3+2. Client-confirmed direction: widen manual to match pelvic rather
     than simplify its content or give it its own row. */
  .sec-05-services__tile--spine-lab {
    grid-column: 1 / 7;
    grid-row: 1 / 3;
  }
  .sec-05-services__tile--pt {
    grid-column: 7 / 13;
    grid-row: 1 / 2;
  }
  .sec-05-services__tile--pelvic {
    grid-column: 7 / 10;
    grid-row: 2 / 3;
  }
  .sec-05-services__tile--manual {
    grid-column: 10 / 13;
    grid-row: 2 / 3;
    /* QA fix (round 4): the "intentional offset to break perfect bento
       alignment" margin-top:1.75rem predates the width fix above and was
       shifting manual's top/bottom edges out of line with pelvic even after
       both tiles were made the same width -- a deliberate design accent that
       now directly contradicts "make manual match pelvic." Removed so the
       two tiles align edge-to-edge like every other same-row pair in this
       grid (spinal-manipulation/needling/iastm, massage/ultrasound/msk). */
  }

  .sec-05-services__tile--manipulation { grid-column: 1 / 5;  grid-row: 3 / 4; }
  .sec-05-services__tile--needling     { grid-column: 5 / 9;  grid-row: 3 / 4; }
  .sec-05-services__tile--iastm        { grid-column: 9 / 13; grid-row: 3 / 4; }

  .sec-05-services__tile--massage      { grid-column: 1 / 5;  grid-row: 4 / 5; }
  .sec-05-services__tile--ultrasound   { grid-column: 5 / 9;  grid-row: 4 / 5; }
  .sec-05-services__tile--msk          { grid-column: 9 / 13; grid-row: 4 / 5; }

  /* QA fix (round 3): manual is now the same 3-column width as pelvic (see
     the grid-column change above), so it no longer needs its own compact
     body/tag/desc treatment -- it uses the base .sec-05-services__body /
     __tag / __desc rules directly, same as pelvic and every other
     non-oversized tile. Removed the old narrow-tile overrides here. */

  /* The two row-3/4 thirds sit shorter than the feature tile, so clamp their
     descriptions to keep every card in the row the same visual weight.
     QA fix (fix-pass-2 item 1): the base .sec-05-services__desc rule caps
     max-width at 34ch sitewide (sized for the wide spine-lab/pt/pelvic
     tiles); these six tiles are already narrower than that 34ch column in
     their own right, so the extra cap forced needless extra line-wraps and
     tripped the clamp early. max-width:100% lets each tile use its own real
     padded width instead of an unrelated fixed character count. */
  .sec-05-services__tile--manipulation .sec-05-services__desc,
  .sec-05-services__tile--needling .sec-05-services__desc,
  .sec-05-services__tile--iastm .sec-05-services__desc,
  .sec-05-services__tile--massage .sec-05-services__desc,
  .sec-05-services__tile--ultrasound .sec-05-services__desc,
  .sec-05-services__tile--msk .sec-05-services__desc {
    max-width: 100%;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
  }

  .sec-05-services__tile--emg {
    grid-column: 1 / 13;
    grid-row: 5 / 6;
  }

  .sec-05-services__tile--spine-lab .sec-05-services__title {
    font-size: var(--fs-h3);
  }
  .sec-05-services__tile--spine-lab .sec-05-services__body {
    padding: 2.25rem;
  }
  .sec-05-services__tile--emg .sec-05-services__body {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.9rem 1.5rem;
  }
  .sec-05-services__tile--emg .sec-05-services__title {
    flex: 0 0 auto;
    order: 1;
  }
  .sec-05-services__tile--emg .sec-05-services__tags {
    flex: 0 0 auto;
    order: 2;
  }
  .sec-05-services__tile--emg .sec-05-services__desc {
    flex: 1 1 320px;
    max-width: 46ch;
    order: 3;
  }
  .sec-05-services__tile--emg .sec-05-services__arrow {
    order: 4;
    margin-left: auto;
  }
}

/* --- Mobile stack --- */
@media (max-width: 860px) {
  .sec-05-services__grid {
    grid-template-columns: 1fr;
    grid-template-rows: none;
  }
  .sec-05-services__tile {
    grid-column: 1 / -1;
    grid-row: auto;
    height: 320px;
    order: 2;
    /* the desktop offset on the small tile would read as a stray gap here */
    margin-top: 0;
  }
  .sec-05-services__tile--spine-lab {
    height: 380px;
    order: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sec-05-services__tile,
  .sec-05-services__photo,
  .sec-05-services__tile::before,
  .sec-05-services__arrow {
    transition: none;
  }
}

/* QA fix (T3 checklist item 7/22): the services bento shipped with no
   bottom "All Services" link, unlike the body-map section's "View All
   Conditions". Given its own scoped rule rather than reusing another
   section's class (that copy-paste has been a recurring T3 bug). */
.sec-05-services__cta {
  display: flex;
  justify-content: center;
  margin-top: clamp(2.5rem, 5vw, 4rem);
}
