/*
  gnat-patches catalog styles.

  These extend the Flyology website kit rather than restate it: the kit owns
  typography, colour tokens, themes, focus treatment, buttons, and the code
  surface, and this file adds the catalog's own denser components — role
  matrices, unified diffs, metadata lists, and rendered bundle prose.
*/

:root {
  --catalog-gap: clamp(1rem, 2.2vw, 1.6rem);
  --catalog-section: clamp(3rem, 6vw, 5rem);
}

/* Layout ------------------------------------------------------------------ */

main {
  padding-bottom: clamp(4rem, 8vw, 7rem);
}

.patch-hero {
  display: grid;
  gap: 1rem;
  padding-block: clamp(3.5rem, 8vw, 6rem) clamp(2rem, 4vw, 3rem);
}

.patch-hero h1,
.page-hero h1 {
  max-width: 22ch;
  margin: 0 0 1rem;
  font-size: clamp(2.2rem, 5vw, 3.6rem);
  line-height: 1.04;
  letter-spacing: -0.02em;
}

.page-hero {
  padding-block: clamp(2rem, 4vw, 3.2rem) clamp(1.5rem, 3vw, 2.4rem);
  border-bottom: 1px solid var(--line);
}

.page-hero > p,
.section-lede {
  max-width: 68ch;
  color: var(--ink-soft);
}

.hero-note {
  max-width: 68ch;
  margin: 0 0 1.6rem;
  padding: 0.75rem 1rem;
  border-left: 3px solid var(--teal);
  background: var(--surface);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--ink-soft);
  font-size: 0.94rem;
}

.section {
  padding-block: var(--catalog-section) 0;
}

/*
  The kit caps h1 and h2 for display headings. A catalog title is a name, not a
  poster line, so card and prose headings set their own measure instead.
*/
.patchset-card h2,
.target-card h2,
.staged-card h2,
.panel-card h2,
.prose h2,
.prose h3,
.prose h4 {
  max-width: 46ch;
}

.section-title {
  margin: 0 0 1rem;
  font-size: clamp(1.35rem, 2.6vw, 1.9rem);
  letter-spacing: -0.015em;
}

.section-action {
  margin-top: 1.8rem;
}

.status-strip .status-inner {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
}

.status-inline {
  margin-top: 1.8rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
}

.status-inline .status-inner {
  width: auto;
  padding-inline: 1.2rem;
}

.status-inline .status-item:first-child {
  padding-left: 0;
}

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  padding-top: 2rem;
  gap: 0.5rem;
  color: var(--ink-soft);
  font-size: 0.85rem;
}

.breadcrumbs span[aria-hidden] {
  color: var(--path);
}

/* Pills and notices ------------------------------------------------------- */

.pill-row {
  display: flex;
  flex-wrap: wrap;
  margin: 1.2rem 0;
  gap: 0.5rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 0.24rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 0.76rem;
  font-weight: 620;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.pill-accepted,
.pill-published,
.pill-current {
  border-color: color-mix(in oklch, var(--violet) 45%, var(--line));
  background: color-mix(in oklch, var(--violet) 12%, var(--surface));
  color: var(--ink);
}

.pill-standalone,
.pill-prerelease {
  border-color: color-mix(in oklch, var(--teal) 50%, var(--line));
  background: color-mix(in oklch, var(--teal) 14%, var(--surface));
  color: var(--ink);
}

.pill-staged,
.pill-none,
.pill-unknown,
.pill-superseded {
  border-style: dashed;
}

.notice {
  padding: 1.1rem 1.3rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.notice p {
  max-width: 72ch;
  margin: 0;
  color: var(--ink-soft);
}

.notice strong {
  color: var(--ink);
}

.notice-superseded {
  margin-top: 1.5rem;
  border-style: dashed;
}

.notice-staged {
  margin-top: var(--catalog-section);
  border-left: 3px solid var(--teal);
}

.notice-staged h3 {
  margin: 1.2rem 0 0.4rem;
  font-size: 0.95rem;
}

/* Tables ------------------------------------------------------------------ */

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--paper);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

caption {
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  text-align: left;
}

th,
td {
  padding: 0.75rem 1.1rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

thead th {
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 0.76rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

tbody tr:last-child th,
tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: color-mix(in oklch, var(--surface) 55%, transparent);
}

.role-table thead th span {
  display: block;
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
}

.role-table tbody th {
  min-width: 15rem;
  font-weight: 620;
}

.role-id,
.staged-id,
.panel-id {
  display: block;
  margin-top: 0.2rem;
  color: var(--ink-soft);
  font-size: 0.76rem;
  font-weight: 400;
}

.role-cell {
  min-width: 9.5rem;
}

.role-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 620;
}

.role-variant,
.role-source {
  display: block;
  margin-top: 0.15rem;
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 0.72rem;
}

.role-patched {
  background: color-mix(in oklch, var(--violet) 10%, transparent);
  box-shadow: inset 3px 0 0 var(--violet);
}

.role-control {
  background: color-mix(in oklch, var(--teal) 12%, transparent);
  box-shadow: inset 3px 0 0 var(--teal-deep);
}

.role-staged {
  background: color-mix(in oklch, var(--surface-strong) 55%, transparent);
  box-shadow: inset 3px 0 0 var(--path);
}

.role-absent .role-label {
  color: var(--ink-soft);
  font-weight: 400;
}

.role-legend {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  margin: 1.4rem 0 0;
  gap: 0.9rem var(--catalog-gap);
}

.role-legend dt {
  font-size: 0.82rem;
  font-weight: 650;
}

.role-legend dd {
  margin: 0.2rem 0 0;
  color: var(--ink-soft);
  font-size: 0.84rem;
}

.bundle-table td:nth-child(2) {
  max-width: 44ch;
  color: var(--ink-soft);
}

.feature-table tbody th {
  min-width: 18rem;
  font-weight: 400;
}

.feature-state {
  min-width: 12rem;
  font-size: 0.84rem;
  font-weight: 620;
}

.feature-verified {
  box-shadow: inset 3px 0 0 var(--teal-deep);
}

.feature-patched {
  box-shadow: inset 3px 0 0 var(--violet);
}

.feature-staged,
.feature-limited,
.feature-other {
  box-shadow: inset 3px 0 0 var(--path);
}

.feature-note {
  max-width: 60ch;
  margin: 0.5rem 0 0;
  color: var(--ink-soft);
  font-size: 0.84rem;
}

/*  A panel title is a sentence, not a version, so it gets its own line. */
.panel-card header {
  display: block;
}

.panel-card h2 {
  margin-bottom: 0.2rem;
}

.panel-card > p {
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.panel-states {
  display: flex;
  flex-wrap: wrap;
  margin: 0;
  padding: 0;
  gap: 0.4rem;
  list-style: none;
}

.panel-states li {
  display: inline-flex;
  align-items: baseline;
  padding: 0.2rem 0.6rem 0.2rem 0.5rem;
  border-left: 3px solid var(--path);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  gap: 0.35rem;
  background: var(--surface);
  font-size: 0.78rem;
}

.panel-states .state-verified {
  border-left-color: var(--teal-deep);
}

.panel-states .state-patched {
  border-left-color: var(--violet);
}

.panel-states span {
  font-weight: 650;
}

.state-legend {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  margin: 0 0 1.6rem;
  gap: var(--catalog-gap);
}

.state-legend-item {
  padding-left: 0.9rem;
  border-left: 3px solid var(--path);
}

.state-legend-item.state-verified {
  border-left-color: var(--teal-deep);
}

.state-legend-item.state-patched {
  border-left-color: var(--violet);
}

.state-legend dt {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.88rem;
  font-weight: 650;
}

.state-legend dt span {
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--ink-soft);
  font-size: 0.74rem;
  font-weight: 620;
}

.state-legend dd {
  margin: 0.25rem 0 0;
  color: var(--ink-soft);
  font-size: 0.84rem;
}

.category-nav ul {
  display: flex;
  flex-wrap: wrap;
  margin: 0;
  padding: 0;
  gap: 0.5rem;
  list-style: none;
}

.category-nav a {
  display: inline-flex;
  align-items: baseline;
  padding: 0.3rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  gap: 0.45rem;
  font-size: 0.84rem;
  text-decoration: none;
}

.category-nav a:hover {
  background: var(--surface);
}

.category-nav a span {
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 0.74rem;
}

.suite-list {
  columns: 2 18rem;
  column-gap: var(--catalog-gap);
}

.disclosure {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--paper);
}

.disclosure > summary {
  display: grid;
  padding: 1.1rem 1.3rem;
  gap: 0.2rem;
  cursor: pointer;
  list-style: none;
}

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

.disclosure > summary::after {
  position: absolute;
  right: 1.3rem;
  content: "+";
  color: var(--ink-soft);
  font-family: var(--font-mono);
}

.disclosure[open] > summary::after {
  content: "\2212";
}

.disclosure > summary {
  position: relative;
}

.disclosure[open] > summary {
  border-bottom: 1px solid var(--line);
}

.disclosure-title {
  padding-right: 2rem;
  font-weight: 650;
}

.disclosure-hint {
  max-width: 70ch;
  color: var(--ink-soft);
  font-size: 0.88rem;
}

.disclosure .prose {
  padding: 1.3rem;
}

.evidence {
  display: inline-block;
  margin-right: 0.4rem;
}

.evidence-case {
  display: inline-block;
  margin-right: 0.3rem;
  padding: 0.05rem 0.4rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 0.74rem;
}

/* Code and diffs ---------------------------------------------------------- */

.code-panel {
  margin: 1.2rem 0;
  overflow: hidden;
  border: 1px solid var(--code-line);
  border-radius: var(--radius-md);
  background: var(--code-bg);
  color: oklch(91% 0.02 270);
}

.code-label {
  padding: 0.6rem 1.1rem;
  border-bottom: 1px solid var(--code-line);
  color: oklch(72% 0.03 270);
  font-family: var(--font-mono);
  font-size: 0.74rem;
}

.code-panel pre {
  tab-size: 8;
}

/*
  The kit styles inline code as a bordered chip through code:not(pre code).
  A diff line is a code element outside a pre, so it inherits that chip and has
  to opt out explicitly.
*/
.diff-code code {
  padding: 0;
  border: 0;
  background: none;
  font-size: inherit;
}

.variant {
  margin-bottom: var(--catalog-section);
}

.variant-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.8rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid var(--line);
}

.variant-header h3 {
  margin: 0;
  font-size: 1.1rem;
}

.variant-header p {
  margin: 0.3rem 0 0;
  color: var(--ink-soft);
  font-size: 0.88rem;
}

.variant-stat,
.diff-stat {
  display: flex;
  gap: 0.7rem;
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.diff-added {
  color: var(--teal-deep);
}

.diff-removed {
  color: var(--ink-soft);
}

.diff-kind {
  color: var(--ink-soft);
}

/*
  Folds. A patch file opens by default because the patch is the point of the
  page; a test source stays closed until a reader asks for it, so a long
  harness cannot bury the evidence above it.
*/
.fold {
  margin: 1rem 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--paper);
}

.fold-stack .fold {
  margin: 0 0 0.7rem;
}

.fold > summary {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 2.6rem 0.7rem 1rem;
  gap: 0.5rem;
  cursor: pointer;
  list-style: none;
}

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

.fold > summary::after {
  position: absolute;
  right: 1.1rem;
  color: var(--ink-soft);
  content: "+";
  font-family: var(--font-mono);
}

.fold[open] > summary::after {
  content: "\2212";
}

.fold > summary:hover {
  background: var(--surface);
}

.fold[open] > summary {
  border-bottom: 1px solid var(--line);
}

.fold-name {
  font-size: 0.9rem;
  font-weight: 620;
}

.fold-meta {
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.fold-body {
  padding: 0 1rem;
}

.fold-body .code-panel {
  margin: 1rem 0 0;
}

.fold-diff .table-scroll {
  border: 0;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  background: var(--code-bg);
}

.diff-table {
  border-collapse: collapse;
  color: oklch(91% 0.02 270);
  font-family: var(--font-mono);
  font-size: clamp(0.7rem, 1.3vw, 0.82rem);
  line-height: 1.7;
  tab-size: 8;
}

.diff-table td {
  padding: 0 0.6rem;
  border: 0;
  white-space: pre;
}

.diff-table tbody tr:hover {
  background: oklch(100% 0 0 / 0.04);
}

.diff-hunk-row td {
  padding: 0.5rem 0.9rem;
  border-block: 1px solid var(--code-line);
  background: oklch(100% 0 0 / 0.04);
  color: oklch(70% 0.03 270);
  white-space: normal;
}

.diff-hunk-range {
  margin-right: 0.8rem;
  font-weight: 650;
}

.diff-hunk-section {
  color: oklch(62% 0.03 270);
}

.diff-number {
  width: 1%;
  color: oklch(58% 0.03 270);
  text-align: right;
  user-select: none;
  -webkit-user-select: none;
}

.diff-marker {
  width: 1%;
  padding-inline: 0.4rem !important;
  user-select: none;
  -webkit-user-select: none;
}

.diff-code {
  width: 100%;
}

.diff-insert {
  background: color-mix(in oklch, oklch(62% 0.14 155) 16%, transparent);
}

.diff-insert .diff-marker {
  color: oklch(76% 0.14 155);
}

.diff-delete {
  background: color-mix(in oklch, oklch(62% 0.16 22) 15%, transparent);
}

.diff-delete .diff-marker {
  color: oklch(74% 0.15 22);
}

.diff-note td {
  padding: 0.35rem 0.9rem;
  color: oklch(66% 0.03 270);
  font-style: italic;
  white-space: normal;
}

.file-action {
  margin: 0.6rem 0 1rem;
  color: var(--ink-soft);
  font-size: 0.85rem;
}

/* Metadata ---------------------------------------------------------------- */

.metadata {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
  margin: 1.2rem 0 0;
  gap: var(--catalog-gap);
}

.metadata-wide {
  grid-template-columns: repeat(auto-fit, minmax(22rem, 1fr));
}

.metadata > div {
  padding-top: 0.8rem;
  border-top: 1px solid var(--line);
  min-width: 0;
}

.metadata dt {
  color: var(--ink-soft);
  font-size: 0.76rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.metadata dd {
  margin: 0.35rem 0 0;
  overflow-wrap: anywhere;
  font-size: 0.92rem;
}

.code-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.code-list li {
  padding: 0.12rem 0;
  overflow-wrap: anywhere;
  font-size: 0.88rem;
}

.is-empty {
  color: var(--ink-soft);
  font-style: italic;
}

/* Patchsets --------------------------------------------------------------- */

.patchset-grid,
.target-grid,
.staged-grid,
.panel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 21rem), 1fr));
  margin-top: 2rem;
  gap: var(--catalog-gap);
}

/*  A compiler card carries a shell command, so it needs a wider minimum. */
.target-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 28rem), 1fr));
}

.patchset-card,
.target-card,
.staged-card,
.panel-card {
  padding: 1.4rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--paper);
}

.patchset-card header,
.staged-card header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
}

.patchset-card h2,
.staged-card h2,
.target-card h2,
.panel-card h2 {
  margin: 0;
  font-size: 1.25rem;
}

.target-card header p {
  margin: 0.3rem 0 1rem;
  color: var(--ink-soft);
  font-size: 0.88rem;
}

.patchset-targets {
  margin: 1.1rem 0 0;
  padding: 0;
  list-style: none;
}

.patchset-targets li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0;
  border-top: 1px solid var(--line);
  gap: 0.5rem;
  font-size: 0.88rem;
}

.patchset-targets code {
  color: var(--ink-soft);
}

.release-state {
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 0.88rem;
}

.release-state p {
  margin: 0;
  color: var(--ink-soft);
}

.release-state p + p {
  margin-top: 0.35rem;
}

.release-published {
  border-color: color-mix(in oklch, var(--violet) 40%, var(--line));
}

.release-none,
.release-unknown {
  border-style: dashed;
}

.bundle-columns {
  display: grid;
  gap: 1.2rem;
  margin-top: 1.4rem;
}

.bundle-column h3 {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin: 0 0 0.2rem;
  font-size: 0.95rem;
}

.bundle-column .count {
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--ink-soft);
  font-size: 0.74rem;
}

.bundle-column p {
  margin: 0 0 0.5rem;
  color: var(--ink-soft);
  font-size: 0.82rem;
}

.bundle-column ul {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.88rem;
}

.bundle-column li {
  padding: 0.2rem 0;
  border-top: 1px solid var(--line);
}

/* Staged ------------------------------------------------------------------ */

.staged-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}

.staged-list li {
  display: grid;
  grid-template-columns: minmax(0, 18rem) minmax(0, 1fr);
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--line);
  gap: 0.4rem var(--catalog-gap);
  align-items: baseline;
}

.staged-list span {
  color: var(--ink-soft);
  font-size: 0.88rem;
}

.staged-card p {
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.staged-card h3 {
  margin: 1rem 0 0.3rem;
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.staged-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: var(--catalog-gap);
}

.staged-links ul {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.88rem;
}

/* Rendered prose ---------------------------------------------------------- */

.prose {
  max-width: var(--reading);
}

.prose > :first-child {
  margin-top: 0;
}

.prose h2,
.prose h3,
.prose h4 {
  margin: 2rem 0 0.6rem;
  letter-spacing: -0.01em;
}

.prose h2 {
  font-size: 1.3rem;
}

.prose h3 {
  font-size: 1.08rem;
}

.prose h4 {
  font-size: 0.98rem;
}

.prose p,
.prose li {
  color: var(--ink-soft);
}

.prose ul,
.prose ol {
  padding-left: 1.2rem;
}

.prose li {
  margin: 0.3rem 0;
}

.prose blockquote {
  margin: 1.2rem 0;
  padding-left: 1rem;
  border-left: 3px solid var(--line);
}

.prose .code-panel {
  max-width: none;
}

.prose-table {
  font-size: 0.88rem;
}

/* Responsive and motion --------------------------------------------------- */

@media (max-width: 60rem) {
  .role-table tbody th,
  .feature-table tbody th {
    min-width: 12rem;
  }

  .staged-list li {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 40rem) {
  .page-hero h1,
  .patch-hero h1 {
    font-size: clamp(1.9rem, 8vw, 2.4rem);
  }

  .metadata,
  .metadata-wide {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .button:hover {
    transform: none;
  }
}
