/* ---------------------------------------------------------------------------
 * Build Digital material card — direction 2D "Compact, pillar-coloured"
 * Review-only overlay for plugin v0.7.0 (baseline ead8cb8, agent/v0.7-quiet-disclosure).
 *
 * Load AFTER assets/draft/client-demo.css. Every selector either overrides a
 * v0.7 rule or styles one of the new classes listed in SPEC.md §4.
 * Colour tokens, fonts and the information model are unchanged.
 *
 * Requires two things from the template (see catalogue-2d-3b.php.txt):
 *   1. --bdk-pillar-color, the material's Digi pillar colour, set inline per card.
 *   2. .bdk-demo-card__inner wrapping the card body, so the expanded layout
 *      can be driven by container queries on the card.
 * --------------------------------------------------------------------------- */

.bdk-client-demo--materials {
  --bdk-radius-card-2d: 0.375rem;
  --bdk-radius-control-2d: 0.25rem;
}

/* --- Card shell -------------------------------------------------------- */

.bdk-demo-card--material {
  container-type: inline-size;
  padding: 0.9rem;
  border: 1px solid var(--bdk-color-border-warm);
  border-top: 0.35rem solid var(--bdk-pillar-color, var(--bdk-color-deep-teal));
  border-radius: var(--bdk-radius-card-2d);
}

/* The Digi pillar is the semantic colour authority. The generated tile variant,
   card edge, actions and Evidence accents all resolve from this same token. */
.bdk-demo-card--material[data-pillar] {
  border-top-color: var(--bdk-pillar-color, var(--bdk-color-deep-teal));
}

.bdk-demo-card__inner {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* --- Identity row: thumbnail + pillar chip + code + meta --------------- */

.bdk-demo-card__identity {
  display: grid;
  grid-template-columns: 3.25rem minmax(0, 1fr);
  gap: 0.65rem;
  align-items: start;
  margin-bottom: 0.55rem;
}

.bdk-demo-card--material .bdk-demo-card__image--thumb {
  margin: 0;
  padding: 0;
  border: 0;
  aspect-ratio: 1;
}

.bdk-demo-card--material .bdk-demo-card__image--thumb .bdk-demo-card__tile-frame {
  border-radius: var(--bdk-radius-control-2d);
}

.bdk-demo-card__identity-lines {
  display: grid;
  gap: 0.3rem;
}

.bdk-demo-card__identity-top {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.4rem;
  align-items: center;
}

/* Pillar becomes a named chip: the hub wordmark is already presented at
   6.8rem in .bdk-demo__pillar-filters directly above the grid. */
.bdk-demo-card--material .bdk-demo-card__pillar {
  gap: 0.3rem;
  align-items: center;
  padding: 0.18rem 0.45rem;
  border-radius: var(--bdk-radius-control-2d);
  color: var(--bdk-color-deep-teal);
  font: inherit;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.bdk-demo-card__pillar-dot {
  width: 0.5rem;
  height: 0.5rem;
  flex: 0 0 auto;
  border-radius: 999px;
  background: currentcolor;
}

/* Public code leaves the artwork: white-on-artwork at 0.58rem was the least
   legible thing on the v0.7 card and its contrast was not ours to control. */
.bdk-demo-card--material .bdk-demo-card__tile-code {
  position: static;
  flex: 0 0 auto;
  padding: 0;
  background: none;
  color: var(--bdk-color-deep-teal);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.66rem;
  font-weight: 700;
  text-shadow: none;
  white-space: nowrap;
}

.bdk-demo-card--material .bdk-demo-card__utility {
  margin: 0;
}

.bdk-demo-card--material .bdk-demo-card__utility .bdk-demo-card__meta {
  gap: 0.35rem;
  justify-content: flex-start;
}

/* --- Title, summary, provenance --------------------------------------- */

.bdk-demo-card--material h2 {
  margin-bottom: 0.5rem;
}

.bdk-demo-card--material .bdk-demo-card__provenance {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 0.65rem;
  align-items: baseline;
  padding: 0.45rem 0;
}

.bdk-demo-card--material .bdk-demo-card__provenance span {
  display: flex;
  gap: 0.3rem;
  align-items: baseline;
  font-size: 0.72rem;
  white-space: nowrap;
}

.bdk-demo-card--material .bdk-demo-card__provenance small {
  letter-spacing: 0.06em;
}

/* --- Disclosure row: count, expand-across, plus ------------------------ */

.bdk-demo-card--material .bdk-demo-card__disclosure > summary {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
}

.bdk-demo-card--material .bdk-demo-card__facts > summary > span:first-child {
  min-width: 0;
  white-space: nowrap;
}

.bdk-demo-card__disclosure-tail {
  display: flex;
  flex: 0 0 auto;
  gap: 0.4rem;
  align-items: center;
  min-width: 0;
}

.bdk-demo-card__disclosure-icon {
  border-radius: var(--bdk-radius-control-2d);
}

.bdk-demo-card--material .bdk-demo-card__disclosure-note {
  white-space: nowrap;
}

/* Expand-across sits inside the summary row, so it costs no height. */
.bdk-demo-card__widen {
  display: grid;
  width: 2.75rem;
  height: 2.75rem;
  margin: -0.65rem 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--bdk-pillar-color, var(--bdk-color-deep-teal));
  cursor: pointer;
  place-items: center;
}

.bdk-demo-card__widen > span {
  display: grid;
  width: 1.35rem;
  height: 1.35rem;
  border: 1px solid #b8d2cf;
  border-radius: var(--bdk-radius-control-2d);
  place-items: center;
}

/* --- Sub-sections ----------------------------------------------------- */

.bdk-demo-card__disclosure-panel {
  padding: 0.15rem 0.6rem 0.4rem;
  border-radius: 0.3rem;
}

.bdk-demo-card__subsection {
  break-inside: avoid;
}

.bdk-demo-card__subsection > summary {
  padding: 0.45rem 0.1rem;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.bdk-demo-card__subsection > summary > span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bdk-demo-card__subsection .bdk-demo-card__disclosure-icon {
  width: 1.15rem;
  height: 1.15rem;
  font-size: 0.85rem;
}

/* --- Feature image ---------------------------------------------------- */

.bdk-demo-card__feature {
  margin: 0 0 0.6rem;
}

.bdk-demo-card__feature-frame {
  position: relative;
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--bdk-color-border-warm);
  border-radius: 0.3rem;
  background: var(--bdk-color-white);
  aspect-ratio: 16 / 10;
}

.bdk-demo-card__feature figcaption {
  margin-top: 0.35rem;
  color: var(--bdk-color-muted);
  font-size: 0.64rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  line-height: 1.4;
}

/* --- Actions ---------------------------------------------------------- */

.bdk-demo-card--material .bdk-demo-card__actions {
  align-self: stretch;
  margin-top: auto;
  padding-top: 0.7rem;
}

.bdk-demo-card--material .bdk-demo-card__link--primary {
  border-color: var(--bdk-pillar-color, var(--bdk-color-deep-teal));
  border-radius: var(--bdk-radius-control-2d);
  background: var(--bdk-pillar-color, var(--bdk-color-deep-teal));
}

.bdk-demo-card--material .bdk-demo-card__link--download {
  border-color: var(--bdk-pillar-color, var(--bdk-color-deep-teal));
  border-radius: var(--bdk-radius-control-2d);
  background: var(--bdk-color-white);
  color: var(--bdk-pillar-color, var(--bdk-color-deep-teal));
}

/* --- Expanded across the grid ----------------------------------------- */

.bdk-demo-card--material.is-expanded {
  /* Full row at any column count, and moved to the front so the cards it
     displaced stay in a full row instead of being stranded. */
  grid-column: 1 / -1;
  order: -1;
}

.bdk-demo-card--material.is-expanded .bdk-demo-card__actions {
  align-self: end;
}

/* Container queries read the CARD's width, so the layout is correct whether or
   not the evidence drawer is open, with no knowledge of the drawer at all. */
@container (min-width: 35rem) {
  .is-expanded .bdk-demo-card__inner {
    display: grid;
    grid-template-columns: minmax(0, 20rem) minmax(0, 1fr);
    gap: 1.35rem;
  }

  .is-expanded .bdk-demo-card__main { grid-area: 1 / 1; }
  .is-expanded .bdk-demo-card__aside { grid-area: 1 / 2 / span 2; min-width: 0; }
  .is-expanded .bdk-demo-card__actions { grid-area: 2 / 1; }
}

@container (min-width: 48.25rem) {
  .is-expanded .bdk-demo-card__disclosure-panel {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.35rem;
    align-items: start;
  }
}

@container (min-width: 77rem) {
  .is-expanded .bdk-demo-card__disclosure-panel {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* --- Narrow-column safety -------------------------------------------- */
/* Without these, holding several columns in a drawer-open workspace makes the
   sub-section tails collide, overflow the card, or wrap one character per line. */

@container (max-width: 48.24rem) {
  .is-expanded .bdk-demo-card__subsection .bdk-demo-card__disclosure-note {
    display: none;
  }

  .is-expanded .bdk-demo-card__classifications dl > div {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.15rem;
  }
}

/* The Uniclass code is the only unbreakable token; never put this on the panel,
   where it breaks prose one character per line. */
.bdk-demo-card__classifications dt {
  overflow-wrap: anywhere;
}

/* --- Motion ---------------------------------------------------------- */
/* The global prefers-reduced-motion block at the end of client-demo.css
   already covers .bdk-demo *, so no new rule is needed here. */
