/*
 * Design system aligned on the companion watch site: semantic colour tokens
 * with soft variants, a prose width and a wide width, a sticky filter bar on
 * large screens only, density-aware cards, and a print stylesheet.
 *
 * No framework, no build step, no external font: the site has to stay readable
 * offline, so the typefaces are declared as stacks that degrade to the system
 * families rather than fetched from a font CDN.
 */

:root {
  color-scheme: light dark;

  --paper: #f3f6f6;
  --card: #ffffff;
  --ink: #17282e;
  --muted: #5a6b70;
  --line: #dce4e4;

  --teal: #0f766e;
  --teal-soft: #e2f0ee;
  --amber: #b07d2b;
  --amber-soft: #f6edda;
  --red: #a8534b;
  --red-soft: #f5e4e2;
  --grey: #64748b;
  --grey-soft: #e8ecf1;

  /* Criticality reuses the palette: red blocks, amber weighs, teal informs. */
  --blocking: var(--red);
  --blocking-soft: var(--red-soft);
  --impacting: var(--amber);
  --impacting-soft: var(--amber-soft);
  --background-level: var(--teal);
  --background-soft: var(--teal-soft);

  /* Widths: card text stays readable, the list spreads into a grid. */
  --prose: 920px;
  --wide: 1520px;

  --card-min: 420px;
  --card-min-compact: 330px;

  --font-body: "Source Sans 3", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    sans-serif;
  --font-display: "Spectral", Georgia, "Times New Roman", serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --radius: 10px;
  --gap: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0e1618;
    --card: #172227;
    --ink: #e7edec;
    --muted: #9fb0b3;
    --line: #2a383c;

    --teal: #5cc0b4;
    --teal-soft: #10312e;
    --amber: #d8a657;
    --amber-soft: #322813;
    --red: #e0938b;
    --red-soft: #331e1b;
    --grey: #93a3b4;
    --grey-soft: #222e36;
  }
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  background: var(--paper);
}

body {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 40px max(20px, env(safe-area-inset-right)) 80px
    max(20px, env(safe-area-inset-left));
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

a {
  color: var(--teal);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

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

/* ---------- Header ---------- */

.eyebrow {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--teal);
}

.page-header h1 {
  margin: 6px 0 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(28px, 5vw, 42px);
  line-height: 1.15;
}

.tagline {
  max-width: var(--prose);
  color: var(--muted);
  font-size: 0.95rem;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 26px;
  margin: 20px 0 24px;
}

.stats div {
  display: flex;
  flex-direction: column;
}

.stats dt {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.stats dd {
  font-size: 1.15rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

/* ---------- Filters ---------- */

.filters {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.field {
  margin-bottom: 14px;
}

.filters input[type="search"] {
  width: 100%;
  max-width: 520px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  font-family: inherit;
  font-size: 1rem;
}

.chips {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 4px 12px;
  align-items: start;
  margin-bottom: 10px;
  border: 0;
}

.chips legend {
  display: contents;
}

.chips legend span,
.group-label {
  padding-top: 7px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.chip[aria-pressed="true"] {
  border-color: var(--teal);
  background: var(--teal);
  color: var(--paper);
}

/*
 * The "all" chip makes the default state visible: without it, "no filter" was
 * only deducible from the absence of an active chip.
 */
.chip-all {
  border-style: dashed;
}

.chip-all[aria-pressed="true"] {
  border-style: solid;
}

.filter-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  margin-top: 12px;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}

button {
  min-height: 34px;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.match-count {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}

/* ---------- Sections ---------- */

.status {
  margin: 48px 0;
  color: var(--muted);
  text-align: center;
}

.section {
  margin-bottom: 32px;
}

.section h2,
.section summary {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.15rem;
}

.section summary {
  cursor: pointer;
  list-style: none;
}

.section summary::-webkit-details-marker {
  display: none;
}

.section summary::before {
  content: "▸";
  color: var(--muted);
  font-family: var(--font-body);
}

.section[open] summary::before {
  content: "▾";
}

.section-note {
  max-width: var(--prose);
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.85rem;
}

.count {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
}

.items {
  display: grid;
  gap: var(--gap);
  margin-top: 14px;
  /* min() keeps a track from overflowing a container narrower than the card. */
  grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--card-min)), 1fr));
  align-items: start;
}

/*
 * Compact density: only the heading and the badges stay visible, and a card
 * opens on demand. Narrower tracks fit more of them across the screen.
 */
.items[data-density="compact"] {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--card-min-compact)), 1fr));
}

.items[data-density="compact"] .card-body {
  display: none;
}

.items[data-density="compact"] .card[data-open="1"] .card-body {
  display: block;
}

/*
 * The blocking section keeps one full-width column whatever the screen: it has
 * to read as an alert, not as a third of a row.
 */
.section--blocking .items {
  grid-template-columns: 1fr;
}

/* ---------- Operating system index ---------- */

.section--os {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
}

.badge--os {
  border-color: var(--teal);
  background: var(--teal-soft);
  color: var(--teal);
}

.os-list {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  list-style: none;
}

.os-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 10px;
  padding: 5px 0;
  border-bottom: 1px solid var(--line);
}

.os-row:last-child {
  border-bottom: 0;
}

.os-row a {
  flex: 1 1 240px;
}

.os-date {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--muted);
}

/* ---------- Cards ---------- */

.card {
  display: grid;
  grid-template-columns: 14px 1fr;
  gap: 16px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
}

/* The left rail carries the criticality, so it reads before any text. */
.card-accent {
  border-radius: 4px;
  background: var(--grey);
}

.card--blocking .card-accent {
  background: var(--blocking);
}

.card--impacting .card-accent {
  background: var(--impacting);
}

.card--background .card-accent {
  background: var(--background-level);
}

.card-main {
  min-width: 0;
}

.card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.badge {
  padding: 2px 9px;
  border: 1px solid currentcolor;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge--blocking {
  background: var(--blocking-soft);
  color: var(--blocking);
}

.badge--impacting {
  background: var(--impacting-soft);
  color: var(--impacting);
}

.badge--background {
  background: var(--background-soft);
  color: var(--background-level);
}

.badge--verified,
.badge--reported {
  border-color: var(--line);
  background: var(--grey-soft);
  color: var(--muted);
}

/*
 * Unverified is the loudest trust marker on the page, and the only dashed one:
 * filled means a level, dashed means a doubt.
 */
.badge--unverified {
  border-style: dashed;
  border-color: var(--red);
  background: transparent;
  color: var(--red);
}

.badge--deadline {
  border-color: var(--blocking);
  background: transparent;
  color: var(--blocking);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  text-transform: none;
}

.card h3 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
  line-height: 1.3;
}

.card h3 a {
  color: var(--ink);
  text-decoration-color: var(--line);
  text-underline-offset: 3px;
}

.card h3 a:hover,
.card h3 a:focus-visible {
  text-decoration-color: var(--teal);
}

.summary {
  max-width: 68ch;
  margin-top: 8px;
}

.evidence {
  max-width: 68ch;
  margin-top: 12px;
  padding: 8px 12px;
  border-left: 3px solid var(--teal);
  border-radius: 0 8px 8px 0;
  background: var(--teal-soft);
  font-size: 0.9rem;
  font-style: italic;
}

.note {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.83rem;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-top: 12px;
  list-style: none;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--muted);
}

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 10px;
  list-style: none;
}

.pills li {
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.75rem;
}

.card-toggle {
  margin-top: 10px;
  padding: 2px 0;
  border: 0;
  background: none;
  color: var(--teal);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  min-height: 0;
}

.items[data-density="detail"] .card-toggle {
  display: none;
}

/* ---------- Footer ---------- */

.page-footer {
  max-width: var(--prose);
  margin-top: 48px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.8rem;
}

/* ---------- Breakpoints ---------- */

/*
 * The filter bar sticks to the top on a large screen only: on a phone it eats
 * too much height to stay visible, and the max-height guard keeps it from
 * swallowing a short window.
 */
@media (min-width: 900px) {
  .filters {
    position: sticky;
    top: 0;
    z-index: 20;
    max-height: 72vh;
    overflow-y: auto;
    margin-right: -20px;
    margin-left: -20px;
    padding-right: 20px;
    padding-left: 20px;
    background: var(--paper);
  }
}

@media (max-width: 700px) {
  .chips {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .chips legend span,
  .group-label {
    padding-top: 0;
  }
}

@media (max-width: 560px) {
  body {
    padding: 24px 14px 60px;
  }

  .card {
    grid-template-columns: 10px 1fr;
    gap: 12px;
    padding: 14px;
  }

  .stats {
    gap: 8px 18px;
  }
}

/* Touch screens have no hover and need targets sized for a finger. */
@media (hover: none) and (pointer: coarse) {
  .chip,
  button:not(.card-toggle) {
    min-height: 44px;
  }

  .toggle input[type="checkbox"] {
    width: 20px;
    height: 20px;
  }
}

@media (max-height: 480px) and (orientation: landscape) {
  body {
    padding-top: 16px;
  }

  .tagline {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- Print: get a clean sheet out ---------- */

@media print {
  .filters,
  .card-toggle,
  .page-footer {
    display: none !important;
  }

  html,
  body {
    max-width: none;
    margin: 0;
    padding: 0;
    background: #fff;
    color: #000;
  }

  .items,
  .items[data-density="compact"] {
    display: block !important;
  }

  .items[data-density="compact"] .card-body {
    display: block !important;
  }

  .section[hidden] {
    display: none !important;
  }

  .card {
    margin-bottom: 12px;
    break-inside: avoid;
  }

  a {
    color: #000;
    text-decoration: underline;
  }
}

/* ---------- Navigation decks ---------- */

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
}

.breadcrumb-sep {
  color: var(--line);
}

.breadcrumb-current {
  color: var(--muted);
  text-transform: uppercase;
}

.deck {
  display: grid;
  gap: var(--gap);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
  margin-bottom: 32px;
}

.deck-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink);
  text-decoration: none;
}

.deck-card:hover,
.deck-card:focus-visible {
  border-color: var(--teal);
}

.deck-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

/*
 * Canonical platform colours. They are what makes a card recognisable at a
 * glance without reproducing a brand mark, and they are lightened in the dark
 * theme so they keep their contrast on a near-black card.
 */
.deck-icon {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  color: var(--muted);
}

.deck-icon--ios {
  color: #5a6b70;
}

.deck-icon--android {
  color: #3ddc84;
}

.deck-icon--react-native {
  color: #2aa3bd;
}

.deck-icon--typescript {
  color: #3178c6;
}

.deck-icon--connectivity,
.deck-icon--nfc {
  color: var(--teal);
}

.deck-icon--ai {
  color: #7c5cd6;
}

.deck-icon--practices {
  color: var(--amber);
}

@media (prefers-color-scheme: dark) {
  .deck-icon--ios {
    color: #9fb0b3;
  }

  .deck-icon--react-native {
    color: #61dafb;
  }

  .deck-icon--typescript {
    color: #7ba6e8;
  }

  .deck-icon--ai {
    color: #b9a3f5;
  }
}

.deck-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.3rem;
  line-height: 1.2;
}

.deck-note {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.deck-badges {
  display: flex;
  gap: 8px;
  margin-top: 2px;
}

/*
 * One counter per criticality, always all three and always in the same order,
 * so a zero is as readable as a number: an empty red badge says "nothing is
 * blocking here", which is information.
 */
.deck-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  padding: 4px 10px;
  border: 1px solid currentcolor;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.deck-badge--blocking {
  background: var(--blocking-soft);
  color: var(--blocking);
}

.deck-badge--impacting {
  background: var(--impacting-soft);
  color: var(--impacting);
}

.deck-badge--background {
  background: var(--background-soft);
  color: var(--background-level);
}

.deck-total {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--muted);
}

#facets-title {
  margin-bottom: 14px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.15rem;
}

@media (hover: none) and (pointer: coarse) {
  .deck-card {
    padding: 18px;
  }
}
