/* EDULIBRARY — canvases 04 Directory, 05 Article, 06 Compare, 07 Utility.
 *
 * Composition corrections measured against the canvases, not inferred. Loaded
 * last so it wins over the earlier passes without raising specificity.
 */

/* ══ 04 · DIRECTORY ══════════════════════════════════════════════════════
   README: "Rows are ruled, not carded; 48px minimum. Filters sit in a left
   group on desktop and become a modal below 760px."
   Measured on the canvas: filter column 280px, result name 21/700, count
   21/700, row = white ground, 16px padding, 1px bottom rule.
   Mine was a three-up card grid with the filters spread across the top. */

@media (min-width: 761px) {
  .page-directory .col-shell {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: var(--s6);
    align-items: start;
  }
  /* Everything sits in the results column unless placed otherwise. */
  .page-directory .col-shell > * { grid-column: 2; }
  .page-directory .col-shell > .record-hero { grid-column: 1 / -1; }
  .page-directory .col-shell > .cdir-filter {
    grid-column: 1; grid-row: 2 / span 99;
    position: sticky; top: var(--s5); align-self: start;
  }
  /* The facets are the column's content, so the disclosure is open by default
     and its summary becomes the group label rather than a control. */
  .page-directory .cdir-facets > summary { display: none; }
  .page-directory .cdir-facets__grid { grid-template-columns: minmax(0, 1fr); gap: var(--s4); }
}

/* Ruled rows, not cards. */
.cdir__grid { grid-template-columns: minmax(0, 1fr); gap: 0; }
.ccard {
  background: var(--surface);
  border: 1px solid var(--rule); border-bottom-width: 1px;
  border-radius: 0;
  padding: var(--s4);
  min-height: var(--target-row);
  gap: 14px;
}
.cdir__grid > li + li .ccard, .cdir__grid > .ccard + .ccard { border-top: 0; }
.ccard:hover { background: var(--surface-alt); }
.ccard__name, .ccard__leadname { font: 700 21px/1.25 var(--font); letter-spacing: -.01em; }
.ccard__meta { font: 400 15px/1.45 var(--font); }
.cdir-filter__count, .cdir-bar__count, .cdir__count { font: 700 21px/1.25 var(--font); color: var(--ink); }
.cdir__group > h2 { font: 700 21px/1.22 var(--font); letter-spacing: -.02em; }

/* An applied filter chip is selected, so it carries the navy fill. */
.cdir-chips a[aria-pressed="true"], .cdir-chips .is-active, .cdir-chips [data-applied] {
  background: var(--field-navy); color: var(--on-navy); border-color: var(--field-navy);
}

/* Below 760 the filter set is a full-width panel with an explicit close.
   ⚠️ This is a disclosure, not a dialog: it is keyboard-operable and works
   with scripting off, which a <dialog> here would not. The canvas draws a
   modal; the behavioural difference is that this does not trap focus. */
@media (max-width: 760px) {
  .page-directory .cdir-facets { border: 1px solid var(--rule); border-radius: var(--r-card); background: var(--surface); }
  .page-directory .cdir-facets > summary {
    display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
    min-height: var(--target); padding: 0 var(--s4);
    font: 700 15px/1.3 var(--font); color: var(--action-blue); cursor: pointer; list-style: none;
  }
  .page-directory .cdir-facets > summary::-webkit-details-marker { display: none; }
  .page-directory .cdir-facets > summary::after { content: '\25BE'; }
  .page-directory .cdir-facets__grid { grid-template-columns: minmax(0, 1fr); padding: 0 var(--s4) var(--s4); }
  .ccard__name, .ccard__leadname { font-size: 18px; }
  .cdir-filter__count, .cdir-bar__count, .cdir__count { font-size: 18px; }
}

/* ══ 05 · ARTICLE ════════════════════════════════════════════════════════
   README: "Desktop: article column with a right TOC rail; below 1180px the
   TOC becomes a disclosure above the text."
   Mine had the disclosure above the text at every width, so the desktop rail
   the canvas draws never existed. */

@media (min-width: 1181px) {
  .pf-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 260px;
    gap: var(--s7);
    align-items: start;
  }
  .pf-panel > * { grid-column: 1; }
  /* The TOC leaves the flow and becomes the rail; open, sticky, not a control. */
  .pf-panel > .ans-toc {
    grid-column: 2; grid-row: 1 / span 99;
    position: sticky; top: var(--s5); align-self: start;
    background: none; border: 0; padding: 0;
    border-left: 1px solid var(--rule); padding-left: var(--s4);
  }
  .pf-panel > .ans-toc > summary {
    font: 700 11px/1 var(--font); letter-spacing: .14em; text-transform: uppercase;
    color: var(--slate); cursor: default; pointer-events: none;
  }
  .pf-panel > .ans-toc > summary::after { content: none; }
  .pf-panel > .ans-toc ol { padding-bottom: 0; }
}

/* The writing-soon shelf must look visibly unfinished — no skeleton that
   reads as content that failed to load. */
.el-unwritten, .answer-shelf__body--unwritten {
  border: 1px dashed var(--rule); background: var(--surface);
}

/* ══ 06 · COMPARE ════════════════════════════════════════════════════════
   The script builds a real <table>. Lead with what differs; never squeeze it
   horizontally — below 760 it is one block per college. */

.cled-shell table { width: 100%; border-collapse: collapse; }
.cled-shell thead th {
  position: sticky; top: 0; z-index: 2; background: var(--surface);
  font: 700 15px/1.3 var(--font); color: var(--ink);
  text-align: left; padding: var(--s3) var(--s4); border-bottom: 1px solid var(--rule);
}
.cled-shell tbody th {
  position: sticky; left: 0; z-index: 1; background: var(--surface);
  font: 700 13px/1.4 var(--font); letter-spacing: .04em; color: var(--slate);
  text-align: left; padding: var(--s3) var(--s4); border-bottom: 1px solid var(--rule-soft);
  white-space: nowrap;
}
.cled-shell tbody td {
  padding: var(--s3) var(--s4); border-bottom: 1px solid var(--rule-soft);
  font: 400 16px/1.5 var(--font); vertical-align: top;
}
@media (max-width: 760px) {
  /* Contained scroll with a visible edge rather than document overflow. */
  .cled-shell { overflow-x: auto; }
  .cled-shell table { min-width: 640px; }
}

/* ══ 07 · UTILITY ════════════════════════════════════════════════════════ */

.search-page, .search-workspace { max-width: 860px; }
/* 320px is an explicit check in the canvas; nothing may exceed the gutter. */
@media (max-width: 360px) {
  .record-hero, .course-v2-hero, .course-hero { padding-inline: var(--s3); }
  .el-utilpage { padding-block: var(--s6); }
}

/* ── Directory: classes the script adds at runtime ───────────────────────
   These never appear in the server-rendered HTML, so a sweep of the built
   pages cannot see them — they were missed by every earlier pass and only
   showed up once the restored directory script was running again. */

/* `edulibrary-directory.js` marks non-matching rows with `is-out`. Without a
   rule the filter reduced the count in the status line while leaving every
   row on screen. */
.is-out { display: none !important; }

.ccard__aside { flex: 0 0 auto; display: grid; gap: var(--s2); align-content: start; }
.ccard__save {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: var(--target); padding: 0 var(--s4);
  background: var(--surface); color: var(--action-blue);
  border: 1px solid var(--rule); border-radius: var(--r-control);
  font: 700 14px/1 var(--font); cursor: pointer; white-space: nowrap;
}
.ccard__save:hover { background: var(--surface-alt); }
.ccard__save[aria-pressed="true"] {
  background: var(--field-navy); color: var(--on-navy); border-color: var(--field-navy);
}

/* action-blue on surface-alt is 4.36:1, under AA. The bar sits on white so
   its two actions clear the floor at 4.62:1 — the pair, not the token. */
.cdir-bar { background: var(--surface); }
