/* Browse products: the capability directory.
   Wide screens list the five capabilities and show the open group's desks on one raised card
   beside the list (directory.js keeps one group open). Phones, and browsers without
   ::details-content, give each capability its own card that opens inline.
   Shared parts (header, footer, .link, .icon-tile, focus, motion) are in styles.css. */

.directory { overflow-x: clip; }  /* the card's glow may reach past a 32 px gutter; the top rhythm is the shared .page-top */

/* ---------- Intro ---------- */
.directory-intro {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; column-gap: 2rem;
  margin-bottom: 2.5rem;
}
.directory-intro h1 { grid-column: 1; }
.directory-intro .lead { grid-column: 1; max-width: 33rem; }
/* The arrow's own side bearing overhangs, so the link text ends on the content edge. The
   negative bottom margin centres the 44 px target on the lead's last line. */
.directory-intro .link { grid-column: 2; grid-row: 1 / 3; margin: 0 -.25rem -.5rem 0; }

/* ---------- Capability groups ---------- */
.product-index { position: relative; isolation: isolate; display: grid; gap: .75rem; }

.product-index summary {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-rows: auto auto;
  align-items: center; align-content: center; column-gap: 1rem;
  min-height: 4.25rem; padding: .5rem 1rem .5rem .5rem;
  border-radius: 1.125rem; list-style: none;
  transition: background-color var(--dur-quick) ease, box-shadow var(--dur-base) var(--ease-out);
}
.product-index summary::-webkit-details-marker { display: none; }
.product-index summary .icon-tile { grid-row: 1 / 3; }
.product-index summary h2 {
  grid-column: 2; align-self: end;
  font: 600 var(--type-body)/var(--leading-body) var(--font-body); letter-spacing: -.005em;
}
.group-count {
  grid-column: 2; grid-row: 2; align-self: start;
  font-size: var(--type-small); line-height: var(--leading-small); color: var(--ink-muted);
}
.product-index summary .chevron {
  grid-column: 3; grid-row: 1 / 3; width: 1.25rem; height: 1.25rem; stroke-width: 2;
  transition: transform var(--dur-state) var(--ease-out), opacity var(--dur-quick) ease;
}

/* The open group: the Soft iris selection row (as in the homepage queue), a weight change, the
   radiant tile (shared: details[open] > summary .icon-tile) and a turned chevron. The same cue
   marks it on phones and wide screens. The other groups' tiles rest on the neutral fill. */
.product-index details[open] > summary {
  background: var(--selection-row);
  box-shadow: inset 0 0 0 1px rgb(48 36 67 / .05);
}
.product-index details[open] > summary h2 { font-weight: 700; }
.product-index details[open] > summary .chevron { transform: rotate(180deg); }
/* Hover lifts a closed row onto white, so it never reads as the Soft iris selection. */
@media (hover: hover) {
  .product-index details:not([open]) > summary:hover { background: rgb(255 255 255 / .85); box-shadow: inset 0 0 0 1px var(--hairline), var(--shadow-1); }
}

/* ---------- Desks ---------- */
/* The card's own width picks the layout: rows when narrow, one row of cards when wide. */
.capability-body { min-width: 0; container-type: inline-size; }
.capability-body ul { list-style: none; padding: 0; display: grid; align-content: start; gap: .5rem; }
.capability-body li { display: grid; }

.desk {
  position: relative;
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-rows: auto auto;
  align-items: center; align-content: center; column-gap: 1rem;
  min-height: 5rem; padding: .875rem 1rem .875rem .875rem;
  border-radius: 1.25rem; color: var(--text); text-decoration: none;
  background: var(--chalk);
  box-shadow: inset 0 0 0 1px var(--hairline);
  transition: transform var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out), background-color var(--dur-quick) ease;
}
.desk .icon-tile { grid-row: 1 / 3; }
.desk-name { grid-column: 2; align-self: end; font-weight: 700; letter-spacing: -.005em; }
.desk-task {
  grid-column: 2; grid-row: 2; align-self: start;
  font-size: var(--type-small); line-height: var(--leading-small); color: var(--ink-muted);
  text-wrap: pretty;
}
.desk-go {
  grid-column: 3; grid-row: 1 / 3;
  display: grid; place-items: center; width: 2.5rem; height: 2.5rem; border-radius: 50%;
  color: var(--plum); background-color: var(--white);
  box-shadow: inset 0 0 0 1px var(--edge);
  transition: background-color var(--dur-quick) ease, color var(--dur-quick) ease, box-shadow var(--dur-base) var(--ease-out);
}
.desk-go .icon { width: 1.125rem; height: 1.125rem; stroke-width: 2; transition: transform var(--dur-base) var(--ease-out); }

/* Hover lifts the card and fills the arrow well, only where a pointer can hover. */
@media (hover: hover) {
  .desk:hover {
    transform: translateY(-3px); background-color: var(--white);
    box-shadow: inset 0 0 0 1px rgb(48 36 67 / .06), var(--shadow-2);
  }
  .desk:hover .desk-go { color: var(--paper); background-color: var(--plum); box-shadow: 0 6px 14px -6px rgb(48 36 67 / .6); }
  .desk:hover .desk-go .icon { transform: translateX(2px); }
}
.desk:active { transform: translateY(0); }

/* Cards: tile and arrow on top, name and task below. The cards share three row tracks through
   subgrid, so names and tasks line up across a group. The name always follows the tile at the
   same 20 px, and each card is as tall as its content; any spare height in the panel stays below
   the cards. */
@container (min-width: 40rem) {
  .capability-body ul {
    grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto; align-content: start; gap: 0 1rem;
  }
  .capability-body li { grid-row: span 3; grid-template-rows: subgrid; }
  .desk {
    grid-row: span 3; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: subgrid;
    align-items: start; row-gap: .25rem; padding: 1.25rem 1.25rem 1.375rem;
  }
  .desk .icon-tile { grid-column: 1; grid-row: 1; }
  .desk-go { grid-column: 2; grid-row: 1; }
  .desk-name { grid-column: 1 / -1; grid-row: 2; margin-top: 1rem; }
  .desk-task { grid-column: 1 / -1; grid-row: 3; }
}

@keyframes panel-in { from { opacity: 0; transform: translateY(6px); } }
@keyframes glow-in { from { opacity: 0; } }

/* ---------- Phones and the inline fallback: one card per capability ---------- */
.product-index details {
  scroll-margin-top: 1rem;
  padding: .375rem; border-radius: var(--radius-card);
  background: rgb(255 255 255 / .62);
  box-shadow: inset 0 0 0 1px var(--hairline);
  transition: background-color var(--dur-state) ease, box-shadow var(--dur-state) var(--ease-out);
}
.product-index details[open] {
  background: var(--raised);
  box-shadow: inset 0 0 0 1px rgb(48 36 67 / .05), var(--shadow-2);
}
.capability-body { padding: .5rem .25rem .25rem; }
.capability-body h3 { margin: .5rem .625rem 1rem; font-size: var(--type-subheading); line-height: var(--leading-subheading); }
/* Entrance: the capabilities rise in turn after the intro, on the .rise d2–d6 timing. Each card
   rises whole, so a row never appears inside an empty card. The delay is a custom property
   because the wide layout moves the entrance to the summary, which inherits through the
   details element's shadow slot rather than from the details itself. */
.product-index > details:nth-child(1) { --rise-delay: 120ms; }
.product-index > details:nth-child(2) { --rise-delay: 180ms; }
.product-index > details:nth-child(3) { --rise-delay: 240ms; }
.product-index > details:nth-child(4) { --rise-delay: 300ms; }
.product-index > details:nth-child(5) { --rise-delay: 360ms; }
@media (prefers-reduced-motion: no-preference) {
  .product-index > details { animation: rise var(--dur-scene) var(--ease-out) var(--rise-delay, 0s) both; }
  .product-index details[open] .capability-body { animation: panel-in var(--dur-state) var(--ease-out) both; }
}

/* ---------- Wide: the list beside one raised card ---------- */
/* 48.01rem matches the query in directory.js, which keeps a group open from this width. */
@supports selector(details::details-content) {
  @media (min-width: 48.01rem) {
    .product-index {
      grid-template-columns: minmax(15rem, 27rem) minmax(0, 1fr);
      grid-template-rows: repeat(5, auto) 1fr;
      align-items: start; column-gap: clamp(2rem, 4vw, 3.5rem); row-gap: .25rem;
    }
    .product-index details, .product-index details::details-content { display: contents; }
    /* The details have no box to move here, so each row takes over the entrance. The open
       group's card and its glow follow once the first rows are in; directory.js sets
       data-settled on the first interaction, so a group opened later appears at once. */
    .product-index > details { animation: none; }
    @media (prefers-reduced-motion: no-preference) {
      .product-index > details > summary { animation: rise var(--dur-scene) var(--ease-out) var(--rise-delay, 0s) both; }
      .product-index:not([data-settled]) details[open] .capability-body { animation-delay: 240ms; }
      .product-index::before { animation: glow-in var(--dur-scene) var(--ease-out) 240ms both; }
    }
    .product-index summary { grid-column: 1; }
    /* The open group's chevron points at its card; the others only show the row. It sits out of
       the flow so the longest group name keeps one line from 1280 px. */
    .product-index summary { position: relative; grid-template-columns: auto minmax(0, 1fr); padding-right: 2.5rem; }
    .product-index summary .chevron { position: absolute; right: 1rem; top: 50%; margin-top: -.625rem; opacity: 0; transform: rotate(-90deg); }
    .product-index details[open] > summary .chevron { opacity: 1; transform: rotate(-90deg); }
    @media (hover: hover) {
      .product-index details:not([open]) > summary:hover .chevron { opacity: .55; }
    }
    .product-index details:not([open]) .capability-body { display: none; }

    /* The card fits its desks and starts level with the first row, so no empty band opens
       inside it below the desk cards. */
    .capability-body {
      grid-column: 2; grid-row: 1 / -1; align-self: start;
      display: flex; flex-direction: column;
      padding: 2.25rem 2.5rem 2.5rem; border-radius: var(--radius-card);
      background: var(--raised);
      box-shadow: inset 0 0 0 1px rgb(48 36 67 / .05), var(--shadow-3);
    }
    .capability-body h3 { margin: 0 0 1.75rem; font-size: var(--type-section); line-height: var(--leading-section); }

    /* One pre-blurred glow behind the card: Periwinkle above, Butter below. */
    .product-index::before {
      content: ""; position: absolute; z-index: -1; grid-column: 2; grid-row: 1 / -1;
      inset: -5rem -4rem -6rem -5rem; pointer-events: none;
      /* Each ellipse fades out inside the box (centre ± radius stays within 0–100%), so no edge shows. */
      background:
        radial-gradient(34% 40% at 64% 42%, rgb(182 185 255 / .4), rgb(182 185 255 / .12) 55%, rgb(182 185 255 / 0) 100%),
        radial-gradient(26% 30% at 27% 68%, rgb(255 241 199 / .8), rgb(255 241 199 / 0) 100%);
    }
  }
  @media (min-width: 48.01rem) and (max-width: 79.99rem) {
    .product-index { grid-template-columns: minmax(14rem, 19rem) minmax(0, 1fr); }
    .capability-body { padding: 1.75rem 1.75rem 2rem; }
  }
}

/* ---------- Phone ---------- */
/* Group and desk tiles keep the shared 52 px tile with 16 px corners, as on every other page. */
@media (max-width: 47.99rem) {
  .directory-intro { grid-template-columns: minmax(0, 1fr); margin-bottom: 1.5rem; }
  .directory-intro .link { grid-column: 1; grid-row: auto; justify-self: start; margin: .5rem 0 0; }
  .product-index { gap: .5rem; }
  .product-index summary { min-height: 4rem; column-gap: .875rem; padding: .5rem .875rem .5rem .5rem; }
  /* The summary already names the group. */
  .capability-body h3 { display: none; }
  .product-index details { padding: .3125rem; }
  .capability-body { padding: .3125rem 0 0; }
  .capability-body ul { gap: .3125rem; }
  .desk { min-height: 4.5rem; column-gap: .75rem; padding: .75rem .625rem .75rem .5rem; border-radius: 1.125rem; }
  .desk-go { width: 2rem; height: 2rem; }
  .desk-go .icon { width: 1rem; height: 1rem; }
}

/* ---------- Forced colours ---------- */
/* Contrast themes drop the tints and shadows that draw these edges, so each card, the arrow well
   and the wide panel get a system border. On wide screens the details have no box. */
@media (forced-colors: active) {
  .desk, .desk-go, .product-index details { border: 1px solid CanvasText; }
}
@supports selector(details::details-content) {
  @media (forced-colors: active) and (min-width: 48.01rem) {
    .capability-body { border: 1px solid CanvasText; }
  }
}
