/* =============================================================================
   Demo-specific layout: catalogue, fail/pass comparison panels, testing blocks.
   Loaded in addition to base.css on demo and catalogue pages.
   ============================================================================= */

/* --- Criterion header -------------------------------------------------------- */
.sc-header { margin-bottom: var(--sp-5); }
.sc-header__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2) var(--sp-3);
  margin-bottom: var(--sp-3);
  font-size: 0.9375rem;
  color: var(--text-muted);
}
.sc-header__number {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}
.sc-header h1 { margin: 0 0 var(--sp-3); }
.sc-header__summary {
  font-size: 1.125rem;
  line-height: 1.6;
  color: var(--text);
  max-width: var(--measure);
}

/* Small pill used for version and automation metadata. Always paired with text. */
.tag {
  display: inline-block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 var(--sp-2);
  font-size: 0.8125rem;
  /* No white-space: nowrap here. A long pill such as "Not detectable
     automatically" is about 28 characters; once the user applies the 1.4.12
     letter-spacing override it grows past a 320px viewport and, unable to wrap,
     pushes the whole page sideways - failing 1.4.10 as a side effect of 1.4.12.
     Two criteria, one missing declaration. */
  max-width: 100%;
}

/* --- Fail / pass comparison ---------------------------------------------------
   Single column at narrow widths so the page reflows to 320px (1.4.10).
   Side by side only when there is genuinely room. */
.compare {
  display: grid;
  gap: var(--sp-5);
  margin: var(--sp-5) 0;
}
/* Belt and braces: every direct child of a demo grid may shrink. */
.compare > *, .card-grid > *, .test-methods > * { min-width: 0; }
@media (min-width: 60rem) {
  .compare { grid-template-columns: 1fr 1fr; }
}

.panel {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-raised);
  display: flex;
  flex-direction: column;
  /* No fixed height: user text-spacing overrides must not clip this (1.4.12) */

  /* min-width: 0 is load-bearing for 1.4.10 Reflow.
     Grid and flex items default to min-width: auto, which refuses to shrink
     below the intrinsic minimum width of their content. The <pre> code blocks
     inside this panel have long unbreakable lines, so without this the panel
     stays as wide as the widest line and the whole page scrolls sideways at
     320px - even though the <pre> itself scrolls perfectly well on its own.
     This is the single most common cause of a reflow failure in a grid layout,
     and it is invisible until you actually render at 320px. */
  min-width: 0;
}
.panel--fail { border-color: var(--fail-border); }
.panel--pass { border-color: var(--pass-border); }

.panel__header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 2px solid inherit;
  font-weight: 700;
}
.panel--fail .panel__header {
  background: var(--fail-bg);
  color: var(--fail);
  border-bottom: 2px solid var(--fail-border);
}
.panel--pass .panel__header {
  background: var(--pass-bg);
  color: var(--pass);
  border-bottom: 2px solid var(--pass-border);
}
/* The glyph is decorative; the adjacent word carries the meaning (1.4.1). */
.panel__header .glyph { font-size: 1.125rem; line-height: 1; }
.panel__body { padding: var(--sp-4); min-width: 0; }
.panel__body > :last-child { margin-bottom: 0; }

/* The live example is isolated in an iframe so a deliberately broken demo cannot
   contaminate the accessibility tree, focus order, or axe results of this page. */
.demo-frame {
  width: 100%;
  min-height: 15rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;         /* frames render their own theme; keep the canvas neutral */
  display: block;
}
.demo-frame__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-3);
  align-items: center;
  margin-top: var(--sp-3);
  font-size: 0.9375rem;
}

/* --- Code blocks with highlighted lines ---------------------------------------
   The highlighted line is marked with a border and a text marker, never colour
   alone (1.4.1 Use of Color). */
.code-block { margin: var(--sp-4) 0; }
.code-block__caption {
  font-size: 0.875rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
}
.code-block__caption + pre { margin-top: 0; border-radius: 0 0 var(--radius) var(--radius); }
mark.line {
  background: var(--note-bg);
  color: var(--text);
  border-left: 3px solid var(--note-border);
  padding-left: var(--sp-2);
  display: inline-block;
  width: 100%;
}

/* --- "How to test" grid -------------------------------------------------------- */
.test-methods {
  display: grid;
  gap: var(--sp-4);
  margin: var(--sp-5) 0;
  padding: 0;
  list-style: none;
}
@media (min-width: 48rem) {
  .test-methods { grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); }
}
.test-methods li {
  border: 1px solid var(--border);
  border-top: 4px solid var(--border-strong);
  border-radius: var(--radius);
  padding: var(--sp-4);
  background: var(--surface);
  max-width: none;
}
.test-methods h3 { margin-top: 0; font-size: 1rem; }
.test-methods p:last-child { margin-bottom: 0; }

/* --- Catalogue ----------------------------------------------------------------- */
.filters {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: var(--sp-4);
  margin-bottom: var(--sp-5);
}
.filters fieldset { border: 0; margin: 0 0 var(--sp-4); padding: 0; }
.filters legend { font-weight: 700; padding: 0; margin-bottom: var(--sp-2); }
.filters__options { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-4); }
.filters__option { display: flex; align-items: center; gap: var(--sp-2); }
.filters__option label { margin: 0; font-weight: 400; }
.filters__option input { min-height: 24px; width: 24px; height: 24px; }

/* The result count is a live region so screen reader users hear filtering
   results without moving focus (4.1.3 Status Messages). */
.filter-status { font-weight: 700; margin: 0 0 var(--sp-4); }

.sc-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-3); }
.sc-card {
  border: 1px solid var(--border);
  border-left: 6px solid var(--border-strong);
  border-radius: var(--radius);
  padding: var(--sp-4);
  background: var(--surface-raised);
  max-width: none;
}
.sc-card[data-level="A"] { border-left-color: var(--level-a); }
.sc-card[data-level="AA"] { border-left-color: var(--level-aa); }
.sc-card[data-level="AAA"] { border-left-color: var(--level-aaa); }
.sc-card__title { margin: 0 0 var(--sp-2); font-size: 1.0625rem; }
.sc-card__title a { text-decoration-thickness: max(1px, 0.06em); }
.sc-card__num { font-family: var(--font-mono); }
.sc-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-3);
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: var(--sp-2);
}
.sc-card p { margin: 0; max-width: var(--measure); }

/* --- Guideline sections on the catalogue ---------------------------------------- */
.guideline-heading {
  margin-top: var(--sp-6);
  padding-bottom: var(--sp-2);
  border-bottom: 2px solid var(--border);
}

/* --- Home page cards ------------------------------------------------------------ */
.card-grid {
  display: grid;
  gap: var(--sp-4);
  list-style: none;
  padding: 0;
  margin: var(--sp-5) 0;
}
@media (min-width: 45rem) {
  .card-grid { grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); }
}
.card {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-5);
  background: var(--surface);
  max-width: none;
}
.card h2, .card h3 { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }

.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-4);
  list-style: none;
  padding: 0;
  margin: var(--sp-5) 0;
}
.stat {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-3) var(--sp-5);
  background: var(--surface);
  max-width: none;
}
.stat__value { display: block; font-size: 1.75rem; font-weight: 700; line-height: 1.2; }
.stat__label { display: block; font-size: 0.9375rem; color: var(--text-muted); }

/* --- Related criteria ------------------------------------------------------------ */
.related-list {
  list-style: none;
  padding: 0;
  margin: var(--sp-3) 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-3);
}
.related-list a {
  display: inline-block;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-1) var(--sp-3);
  min-height: 24px;
  background: var(--surface);
  text-decoration: none;
}
.related-list a:hover { background: var(--surface-raised); text-decoration: underline; }

/* --- Prev / next criterion navigation --------------------------------------------- */
.sc-pager {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-top: var(--sp-7);
  padding-top: var(--sp-4);
  border-top: 2px solid var(--border);
}
.sc-pager a { max-width: 22rem; }
.sc-pager__dir { display: block; font-size: 0.875rem; color: var(--text-muted); }
