/* What the three apps share: the reset, links and code, the theme picker, the segmented
   switch, chips, the version pill, tags, the search box and the sticky finder, the listing
   table, the panel's header and the toast; then the suite bar and the landing page.
   Taken from HCI Ref's stylesheet; where Spec Diff or Spec PDUs name the same thing
   differently, a comment says which name won. Each app's stylesheet loads after this one
   and adds its own columns, widths and views. */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.5 var(--sans);
  -webkit-text-size-adjust: 100%;
  /* keep permalinked rows clear of the sticky search bar and table header */
  scroll-padding-top: calc(var(--finder-h) + 3.5rem);
}

body { margin: 0; }

a { color: inherit; text-decoration-color: color-mix(in srgb, currentColor 40%, transparent); text-underline-offset: 0.18em; }
a:hover { text-decoration-color: currentColor; }
.external::after { content: "\2197"; display: inline-block; margin-left: 0.15em; font-size: 0.85em; color: var(--muted); text-decoration: none; }

code, kbd, pre { font-family: var(--mono); font-size: 0.9375em; font-variant-numeric: tabular-nums; }

button { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 2px; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden; clip-path: inset(50%);
  white-space: nowrap; border: 0;
}

.skip { position: absolute; left: var(--gutter); top: -3rem; padding: 0.5rem 0.75rem; background: var(--ink); color: var(--paper); z-index: 10; }
.skip:focus { top: 0.75rem; }

::highlight(match) { background-color: var(--mark); color: var(--ink); }

/* Theme: follow the system, light or dark */

.theme { flex: none; align-self: start; display: flex; gap: 2px; margin: 0; padding: 2px; border: 1px solid var(--line); border-radius: 999px; }
.theme label { position: relative; display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 999px; color: var(--muted); cursor: pointer; }
.theme input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.theme svg { width: 1rem; height: 1rem; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.theme label:hover { color: var(--ink); background: var(--raise); }
.theme label:has(input:checked) { background: var(--ink); color: var(--paper); }
.theme label:has(input:focus-visible) { outline: 2px solid var(--blue); outline-offset: 2px; }

/* The version, and tags: a variant, a signal, a version in a list. Where a tag sits after
   a name, the app gives it its margin. */

.version { padding: 0.0625rem 0.5rem; border-radius: 4px; background: var(--ink); color: var(--paper); font-weight: 700; white-space: nowrap; }

.tag {
  display: inline-block;
  padding: 0 0.375rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  font: 600 0.75rem/1.5 var(--sans);
  color: var(--muted);
  vertical-align: 0.1em;
  white-space: nowrap;
}
a.tag { border-color: var(--edge); color: var(--ink); text-decoration: none; }
a.tag:hover { background: var(--raise); }

/* Search bar: the views, the search box and what else an app puts there. It sticks to the
   top of the window while the table scrolls; the app's script measures it into --finder-h,
   so the table header sticks under it. */

.finder { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: stretch; }
@media (min-width: 48rem) {
  .finder { position: sticky; top: 0; z-index: 3; padding-block: 0.75rem; margin-block: -0.75rem; background: var(--paper); }
}

.switch { display: flex; margin: 0; padding: 0; border: 0; }
.switch label { position: relative; display: flex; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.switch label > span {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  min-height: 2.75rem;
  padding: 0 1rem;
  border: 1.5px solid var(--edge);
  font-weight: 650;
  white-space: nowrap;
}
/* every segment overlaps the one before it (Spec Diff's rule; HCI Ref's moved only the last) */
.switch label + label > span { margin-left: -1.5px; }
.switch label:first-of-type > span { border-radius: 6px 0 0 6px; }
.switch label:last-of-type > span { border-radius: 0 6px 6px 0; }
.switch .n { font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }
.switch label:hover > span { background: var(--raise); }
.switch input:checked + span { position: relative; background: var(--ink); border-color: var(--ink); color: var(--paper); }
.switch input:checked + span .n { color: inherit; opacity: 0.75; }
.switch input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 2px; }

.search { position: relative; flex: 1 1 20rem; max-width: 40rem; }
.search input {
  width: 100%;
  font: 400 1.0625rem var(--sans);
  color: var(--ink);
  background: var(--paper);
  border: 1.5px solid var(--edge);
  border-radius: 6px;
  padding: 0.75rem 3rem 0.75rem 0.875rem;
  appearance: none;
}
.search input::placeholder { color: var(--muted); }
.search input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-tint); }
.search kbd {
  position: absolute; right: 0.75rem; top: 50%; translate: 0 -50%;
  padding: 0 0.4rem; border: 1px solid var(--line); border-radius: 4px;
  font-size: 0.8125rem; color: var(--muted);
}
.search input:focus + kbd, .search input:not(:placeholder-shown) + kbd { display: none; }

@media (max-width: 47.99rem) {
  /* the views on one row: the counts are above the table anyway */
  .switch .n { display: none; }
  .switch label > span { padding: 0 0.75rem; font-size: 0.9375rem; }
  .search { flex-basis: 100%; }
}

/* Chips: radio buttons drawn as pills, each with a count */

.chip-list { display: flex; flex-wrap: wrap; gap: 0.375rem; }
.chips label { position: relative; }
.chips input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chips label > span {
  display: inline-block;
  padding: 0.3rem 0.75rem;
  border: 1px solid var(--edge);
  border-radius: 999px;
  font-size: 0.9375rem;
  font-weight: 600;
  white-space: nowrap;
}
.chips .n { font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }
.chips label:hover > span { background: var(--raise); }
.chips label.is-zero > span { border-color: var(--line); color: var(--muted); }
.chips input:checked + span { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.chips input:checked + span .n { color: inherit; opacity: 0.75; }
.chips input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 2px; }

/* The listing table. Fixed column widths: it never grows wider than its column, and the
   columns don't move as rows are filtered; each app sets its own. A row that opens
   something has an id (HCI Ref) or a data-id (Spec Diff, Spec PDUs). */

.listing { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: 0.9375rem; }
.listing thead th {
  position: sticky; top: var(--finder-h); z-index: 2;
  background: var(--paper);
  box-shadow: inset 0 -1.5px 0 var(--ink); /* a border wouldn't stick with the cell */
  padding: 0.625rem 0.625rem 0.5rem;
  text-align: left;
  vertical-align: bottom;
  font-size: 0.875rem;
  font-weight: 700;
  white-space: nowrap;
}
.listing th button {
  font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer;
  display: inline-flex; align-items: center; gap: 0.25rem;
}
.listing th button::after { content: ""; width: 0.6em; height: 0.6em; opacity: 0.6; background: currentColor; clip-path: polygon(50% 0, 100% 40%, 0 40%, 0 60%, 100% 60%, 50% 100%); }
.listing th[aria-sort="ascending"] button::after { opacity: 1; clip-path: polygon(50% 15%, 100% 75%, 0 75%); }
.listing th[aria-sort="descending"] button::after { opacity: 1; clip-path: polygon(0 25%, 100% 25%, 50% 85%); }

.listing tbody tr { border-bottom: 1px solid var(--line); }
.js .listing tbody tr:is([id], [data-id]) { cursor: pointer; }
.listing tbody tr:is([id], [data-id]):hover { background: var(--raise); }
.listing tbody tr.is-selected { background: var(--blue-tint); box-shadow: inset 3px 0 0 var(--blue); }
.listing tbody tr.is-selected:has(+ .detail-row) { border-bottom-color: transparent; }
.listing tbody th, .listing td { padding: 0.5rem 0.625rem; text-align: left; vertical-align: baseline; }
.listing tbody th { font-weight: 400; }

/* The details of the selected row, opened under it on narrow screens */
.listing tr.detail-row { background: var(--paper); box-shadow: inset 3px 0 0 var(--blue); }
.listing tr.detail-row > td { padding: 0.25rem 1rem 1.25rem 1.25rem; }

@media (max-width: 47.99rem) {
  /* phones: each row becomes a small block; the app places its cells with grid areas */
  .listing thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .listing, .listing tbody { display: block; }
  .listing tbody tr:is([id], [data-id]) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.25rem 1rem;
    padding: 0.875rem 0;
  }
  .listing tbody th, .listing td { width: auto; padding: 0; }
  .listing tbody tr.is-selected { padding-inline: 0.75rem; }
  .listing tr.detail-row { display: block; }
  .listing tr.detail-row > td { display: block; padding: 0.25rem 0.75rem 1.25rem; }
}

/* The panel's header: a small label and the close button, the title, a row of links (the
   spec section, copy link), copy buttons. Each app keeps its panel's width and body.
   HCI Ref's names won: Spec Diff's .panel-top and .panel-label and Spec PDUs' .detail-top
   are .decoder-top and .decoder-label; Spec Diff's .sec-links and Spec PDUs' .detail-links
   are .details-meta. Section titles in words (.sec-title, .detail-title) stay the apps'. */

.decoder-top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 2rem; margin-bottom: 0.5rem; }
.decoder-label { margin: 0; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.decoder-name { font: 650 1rem var(--mono); overflow-wrap: anywhere; }
.decoder-name.is-words { font-family: var(--sans); }
.details-meta { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; margin: 0; font-size: 0.875rem; color: var(--muted); }
.details-meta a { color: var(--ink); font-weight: 600; }

.close, .copy {
  display: inline-grid; place-items: center; flex: none;
  padding: 0; border: 0; border-radius: 999px;
  background: transparent; color: var(--muted); cursor: pointer;
}
.close { width: 2rem; height: 2rem; border: 1px solid var(--line); color: var(--ink); }
.copy { width: 1.75rem; height: 1.75rem; border-radius: 4px; }
.close svg, .copy svg { width: 1rem; height: 1rem; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.close:hover, .copy:hover { color: var(--ink); background: var(--raise); }
html:not(.js) .copy { display: none; }

/* "Copied", "Link copied" */
.toast {
  position: fixed; left: 50%; bottom: 1.5rem; z-index: 20;
  margin: 0; padding: 0.5rem 1rem; border-radius: 999px;
  background: var(--ink); color: var(--paper); font-size: 0.875rem; font-weight: 600;
  translate: -50% 0.5rem; opacity: 0; pointer-events: none;
  transition: opacity 150ms, translate 150ms;
}
.toast.is-shown { opacity: 1; translate: -50% 0; }

/* The suite bar: BlueTools, the three apps and the theme, in one line above the app. It
   doesn't stick. Its row keeps the page column, so the mark sits over the app's title; its
   rule runs the width of the window. The apps are quiet text with an ink underline on the
   one open, as Spec PDUs' view links, so they never look like an app's own view switch.
   Phones: the mark and the theme, then the apps. */

.suite { border-bottom: 1px solid var(--line); }
.suite-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0 2.25rem;
  min-height: 2.75rem; padding-inline: var(--gutter); /* the row spans the window: the three apps have three page widths, so the bar aligns with none and reads as its own level */
}
.suite-mark { display: inline-flex; align-items: center; gap: 0.5rem; font-weight: 750; letter-spacing: -0.01em; text-decoration: none; }
.suite-mark:hover { text-decoration: underline; }
.suite-mark svg { flex: none; width: 1.375rem; height: 0.625rem; }
.suite-mark rect:first-child { fill: var(--blue); }
.suite-mark rect:last-child { fill: var(--amber); }
.suite-tabs { display: flex; align-self: stretch; gap: 1.5rem; }
.suite-tabs a {
  display: flex; align-items: center;
  margin-bottom: -1px; border-bottom: 2px solid transparent; /* the underline sits on the rule */
  font-size: 0.9375rem; font-weight: 650; color: var(--muted); text-decoration: none;
}
.suite-tabs a:hover { color: var(--ink); }
.suite-tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--ink); }
.suite .theme { align-self: center; margin-left: auto; }
.suite .theme label { width: 1.75rem; height: 1.75rem; } /* a step quieter than in an app's header */

@media (max-width: 47.99rem) {
  .suite-row { padding-top: 0.25rem; }
  .suite-tabs { order: 1; flex-basis: 100%; min-height: 2.5rem; }
}

/* The landing page: one line of what this is, and a card for each app, drawn like Spec
   PDUs' protocol tiles: the app's logo, its name and one line. The last app used is
   marked, not opened. */

.landing { max-width: var(--page); margin-inline: auto; padding: clamp(2rem, 5vw, 4rem) var(--gutter) 4rem; }
.landing h1 { margin: 0 0 0.875rem; font-size: clamp(2.125rem, 1.5rem + 2.4vw, 3rem); font-weight: 750; line-height: 1; letter-spacing: -0.025em; }
.landing-line { max-width: 52rem; margin: 0 0 2rem; font-size: 1.0625rem; color: var(--muted); text-wrap: pretty; }
.apps { display: grid; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); gap: 0.75rem; max-width: 64rem; margin: 0; padding: 0; list-style: none; }
.app-card {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-content: start; gap: 0.25rem 0.75rem;
  height: 100%; padding: 0.875rem 1rem 1rem; border: 1px solid var(--edge); border-radius: 8px;
  text-decoration: none;
}
.app-card:hover { background: var(--raise); border-color: var(--ink); }
.app-card.is-last { border-color: var(--ink); }
.app-logo { align-self: center; width: 1.75rem; height: 1.75rem; }
.app-logo svg { display: block; width: 1.75rem; height: 1.75rem; }
/* The inline logo in the theme's colours. These outrank the logo's own <style>, which has
   the light and dark values for the favicon, by the system's setting alone. */
.app-logo .b { fill: var(--blue); }
.app-logo .a { fill: var(--amber); }
.app-logo .g { fill: var(--edge); }
.app-logo .m { stroke: var(--muted); }
.app-name { margin: 0; font-size: 1.25rem; font-weight: 750; letter-spacing: -0.01em; }
.app-last { align-self: center; font-size: 0.8125rem; color: var(--muted); }
.app-line { grid-column: 1 / -1; margin: 0; text-wrap: pretty; }

/* Touch screens: bigger targets */

@media (pointer: coarse) {
  .close { width: 2.75rem; height: 2.75rem; }
  .copy { width: 2.5rem; height: 2.5rem; }
  .theme label, .suite .theme label { width: 2.25rem; height: 2.25rem; }
  .search kbd { display: none; }
  .chips label > span { padding-block: 0.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; }
}

/* High contrast: system colours draw what the ink fill and the inset bar showed */

@media (forced-colors: active) {
  .theme label:has(input:checked), .switch input:checked + span, .chips input:checked + span { forced-color-adjust: none; background: Highlight; border-color: Highlight; color: HighlightText; }
  .listing tbody tr.is-selected { outline: 2px solid Highlight; outline-offset: -2px; }
  .suite-tabs a { forced-color-adjust: none; color: LinkText; }
  .suite-tabs a[aria-current="page"] { color: CanvasText; border-bottom-color: CanvasText; }
}
