/**
 * Capabilities page signature interaction: five full-bleed panels. Image
 * and panel edges never move. Only the text block slides (alternating
 * left/right per panel); the space it vacates reveals the capability's
 * services as a brick-tile layout. One panel open at a time, 80ms hover
 * intent (JS), keyboard-focusable, Escape closes (capabilities.js).
 *
 * No-JS / below 1024px with JS: a single always-reachable "Show services"
 * button + an in-flow collapsible panel - the no-JS default has it fully
 * expanded (services "visible under each panel" without JS), per R6.
 */

.cap-row {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border-radius: var(--radius-xl);
  min-height: 300px;
  margin-bottom: 1.5rem;
  background: var(--navy); /* safety base under any transparent/light image area */
}
@media (min-width: 1024px) {
  .cap-row { min-height: 420px; }
}

.cap-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
/* Uniform-strength wash (not a directional fade) - contrast for text/
   tiles must hold regardless of which side they're on, since the text
   block and services swap sides depending on dir and open state.
   Verified: white text 8.68:1, light-teal text 4.99:1 against this,
   against a worst-case all-white source image. */
.cap-scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(16,38,62,.88) 0%, rgba(16,38,62,.82) 100%);
}

.cap-text {
  position: relative;
  z-index: 3;
  max-width: 90%;
  padding: 1.75rem;
  pointer-events: none;
}
@media (min-width: 1024px) {
  /* Text defaults to the SAME side its row will open toward (left row ->
     text left, right row -> text right) and services always render on the
     opposite side - the two never overlap regardless of translate amount,
     since 46% + 50% + a gutter fits inside 100% by construction. The
     slide on open is a small decorative nudge, not what prevents overlap. */
  .cap-text {
    position: absolute;
    top: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    max-width: 46%;
    padding: 2.5rem;
  }
  [data-dir="left"] .cap-text { left: 0; }
  [data-dir="right"] .cap-text { right: 0; text-align: right; align-items: flex-end; }
  html.js .cap-text {
    transition: transform var(--m-duration-base) var(--m-ease-out);
  }
  html.js .cap-row.is-open[data-dir="left"] .cap-text { transform: translateX(-.75rem); }
  html.js .cap-row.is-open[data-dir="right"] .cap-text { transform: translateX(.75rem); }
}
.cap-text a, .cap-text button { pointer-events: auto; }
.cap-objective {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--teal-light);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.cap-title-link {
  display: inline-block;
  margin-top: .5rem;
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 600;
  color: var(--white);
  text-decoration: none;
}
.cap-title-link:hover { text-decoration: underline; }

/* ---- Desktop full-bleed hit toggle + overlay services panel ---- */
.cap-hit { display: none; }
.cap-services { display: none; }
@media (min-width: 1024px) {
  html.js .cap-hit {
    display: block;
    position: absolute;
    inset: 0;
    z-index: 2;
    width: 100%;
    height: 100%;
    cursor: pointer;
    background: transparent;
    border: 0;
    padding: 0;
  }
  html.js .cap-services {
    display: block;
    position: absolute;
    inset: 0;
    z-index: 4;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--m-duration-base) var(--m-ease-out);
  }
  html.js .cap-row.is-open .cap-services { opacity: 1; pointer-events: auto; }

  .cap-services-inner {
    position: absolute;
    top: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 2.5rem;
    max-width: 50%;
  }
  /* Only one of left/right is ever set - avoids the inset:0 + max-width
     over-constraint that pins the box left regardless of this override. */
  [data-dir="left"] .cap-services-inner { right: 0; text-align: right; align-items: flex-end; }
  [data-dir="right"] .cap-services-inner { left: 0; }
}

/* ---- Brick-tile service layout (glass over imagery - R5 allowed use) ---- */
.brick-tiles {
  display: flex;
  flex-wrap: wrap;
  gap: .625rem;
}
[data-dir="left"] .brick-tiles { justify-content: flex-end; }
.brick-tile {
  flex: 1 1 auto;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.3);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  color: var(--white);
  font-size: var(--text-xs);
  font-weight: 500;
  padding: .55rem .75rem;
  line-height: 1.3;
}
.brick-tile:nth-child(3n+1) { flex-basis: 58%; }
.brick-tile:nth-child(3n+2) { flex-basis: 34%; margin-top: 1rem; }
.brick-tile:nth-child(3n)   { flex-basis: 44%; margin-top: .4rem; }

html.js .cap-services .brick-tile {
  opacity: 0;
  transform: translateX(16px);
  transition: opacity var(--m-duration-base) var(--m-ease-out), transform var(--m-duration-base) var(--m-ease-out);
}
[data-dir="left"] .cap-services .brick-tile { transform: translateX(16px); }
[data-dir="right"] .cap-services .brick-tile { transform: translateX(-16px); }
html.js .cap-row.is-open .cap-services .brick-tile { opacity: 1; transform: none; }
.cap-services .brick-tile:nth-child(1) { transition-delay: 0ms; }
.cap-services .brick-tile:nth-child(2) { transition-delay: 40ms; }
.cap-services .brick-tile:nth-child(3) { transition-delay: 80ms; }
.cap-services .brick-tile:nth-child(4) { transition-delay: 120ms; }
.cap-services .brick-tile:nth-child(5) { transition-delay: 160ms; }
.cap-services .brick-tile:nth-child(6) { transition-delay: 200ms; }
.cap-services .brick-tile:nth-child(7) { transition-delay: 240ms; }
.cap-services .brick-tile:nth-child(8) { transition-delay: 280ms; }
.cap-services .brick-tile:nth-child(9) { transition-delay: 320ms; }
.cap-services .brick-tile:nth-child(10) { transition-delay: 360ms; }

.view-capability-link {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  margin-top: 1rem;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--white);
}

/* ---- Mobile / no-JS: in-flow collapsible "Show services" ---- */
.cap-mobile-toggle {
  display: none;
}
html.js .cap-mobile-toggle {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  min-height: 44px;
  margin-top: .75rem;
  padding: 0 1rem;
  border-radius: var(--radius-full);
  background: rgba(255,255,255,.16);
  color: var(--white);
  font-size: var(--text-sm);
  font-weight: 600;
  position: relative;
  z-index: 3;
}
@media (min-width: 1024px) {
  html.js .cap-mobile-toggle { display: none; }
}
.cap-mobile-toggle-icon { transition: transform var(--m-duration-base) var(--m-ease-out); }
.cap-mobile-toggle[aria-expanded="true"] .cap-mobile-toggle-icon { transform: rotate(180deg); }

/* No-JS default: a plain visible block (no custom hide mechanism needed -
   "services visible under each panel" without JS, per R6). JS (app's
   capabilities.js) sets the native `hidden` attribute on init, once it has
   confirmed it can run the toggle, then flips it on each button click -
   the browser handles the show/hide natively and reliably; a CSS
   grid-rows height animation here proved fragile (content could still
   leak a sliver through a collapsed 0fr track), so this trades a
   transition for correctness. */
.cap-services-mobile {
  position: relative;
  z-index: 3;
}
.cap-services-mobile-inner {
  padding: 0 1.75rem 1.75rem;
}
@media (min-width: 1024px) {
  .cap-services-mobile { display: none; }
  .cap-mobile-toggle { display: none; }
}
.brick-tiles-mobile {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .625rem;
}
.brick-tiles-mobile .brick-tile:nth-child(even) { margin-top: 1rem; }
.brick-tiles-mobile .brick-tile:nth-child(odd) { margin-top: 0; }

@media (prefers-reduced-motion: reduce) {
  html.js .cap-text,
  html.js .cap-services,
  html.js .cap-services .brick-tile {
    transition: none !important;
  }
}
