/* /projects/ catalog (pc-*) and project detail pages (pd-*). Colors come from the tokens in local-overrides.css. */

.pc-page [hidden] {
  display: none !important;
}

.pc-pending .pc-page section {
  visibility: hidden;
}

/* main.css colors bare spans; labels inside links must follow the link. */
html a.pc-link span,
html a.pc-type-link span {
  color: inherit;
}

/* ---------- Page width and text ---------- */

/* Same width as the navigation bar. Only pages with the catalog are wider. */
html .container[role="main"]:has(.pc-page) {
  max-width: 1320px;
}

.pc-page,
.pd-page {
  font-weight: 400;
}

/* ---------- Catalog header ---------- */

/* Takes back part of the container's top margin. */
.pc-page {
  margin-top: -1.5rem;
}

.pc-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0 1.5rem;
  margin-bottom: 1rem;
}

html .pc-header .post-title {
  margin: 0;
  font-size: 2.1rem;
}

.pc-lede {
  order: 1;
  flex-basis: 100%;
  margin: 0.25rem 0 0;
  color: var(--global-text-color-light);
}

.pc-header-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.25rem;
  margin: 0;
  font-size: 0.9rem;
}

/* ---------- Resource types ---------- */

.pc-types {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

html a.pc-type-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 2.5rem;
  padding: 0.3rem 0.8rem;
  border: 1px solid var(--global-divider-color);
  border-radius: 8px;
  background: var(--global-card-bg-color);
  color: var(--global-text-color);
  font-size: 0.86rem;
  font-weight: 600;
  text-decoration: none;
}

html a.pc-type-link i {
  color: var(--global-theme-color);
}

html a.pc-type-link:hover {
  border-color: var(--global-theme-color);
  color: var(--global-text-color);
}

html a.pc-type-link[aria-current] {
  border-color: var(--global-theme-color);
  background: var(--global-theme-color);
  color: var(--global-hover-text-color);
}

html a.pc-type-link[aria-current] i {
  color: inherit;
}

.pc-count {
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  opacity: 0.8;
}

/* ---------- Toolbar ---------- */

.pc-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 2fr) repeat(3, minmax(0, 1fr)) auto;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.pc-toolbar label {
  position: relative;
  margin: 0;
}

.pc-search i {
  position: absolute;
  top: 50%;
  left: 0.75rem;
  transform: translateY(-50%);
  color: var(--global-text-color-light);
  font-size: 0.85rem;
  pointer-events: none;
}

html .pc-toolbar input,
html .pc-toolbar select,
html .pc-toolbar button {
  height: 2.5rem;
  border: 1px solid var(--global-divider-color);
  border-radius: 8px;
  background-color: var(--global-bg-color);
  color: var(--global-text-color);
  font-size: 0.88rem;
}

html .pc-toolbar input {
  width: 100%;
  padding: 0 0.6rem 0 2.1rem;
}

html .pc-toolbar input::placeholder {
  color: var(--global-text-color-light);
  opacity: 1;
}

html .pc-toolbar select {
  width: 100%;
  padding: 0 0.5rem;
  text-overflow: ellipsis;
}

.pc-views {
  display: flex;
}

html .pc-views button {
  width: 2.5rem;
  color: var(--global-text-color-light);
  cursor: pointer;
}

html .pc-views button:first-child {
  border-radius: 8px 0 0 8px;
}

html .pc-views button:last-child {
  border-left: 0;
  border-radius: 0 8px 8px 0;
}

html .pc-views button[aria-pressed="true"] {
  background: var(--aria-btn-bg);
  color: var(--aria-btn-text);
}

html .pc-more {
  display: none;
}

.pc-resources {
  display: flex;
  flex-wrap: wrap;
  grid-column: 1 / -1;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.86rem;
}

.pc-resources > span {
  color: var(--global-text-color-light);
}

html .pc-resources button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  height: 2rem;
  padding: 0 0.7rem;
  border-radius: 1rem;
  font-size: 0.82rem;
  cursor: pointer;
}

html .pc-resources button:hover {
  border-color: var(--global-theme-color);
}

html .pc-resources button span {
  color: inherit;
}

html .pc-resources button i {
  color: var(--global-theme-color);
}

html .pc-resources button[aria-pressed="true"] {
  border-color: var(--global-theme-color);
  background: var(--global-theme-color);
  color: var(--global-hover-text-color);
}

html .pc-resources button[aria-pressed="true"] i {
  color: inherit;
}

html .pc-page .is-empty:not([aria-current], [aria-pressed="true"]) {
  border-style: dashed;
  color: var(--global-text-color-light);
}

.pc-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.6rem;
  min-height: 1.9rem;
  margin-bottom: 0.5rem;
  font-size: 0.88rem;
}

.pc-status p {
  margin: 0;
  color: var(--global-text-color-light);
  font-variant-numeric: tabular-nums;
}

.pc-examples {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 0.75rem;
  margin-left: auto !important;
}

.pc-active {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

html button.pc-chip,
html button.pc-clear {
  min-height: 1.75rem;
  padding: 0.1rem 0.65rem;
  border: 1px solid var(--aria-btn-border);
  border-radius: 6px;
  background: var(--aria-btn-bg);
  color: var(--aria-btn-text);
  font-size: 0.82rem;
  cursor: pointer;
}

html button.pc-chip::after {
  content: " ×";
}

html button.pc-clear {
  border-color: transparent;
  background: none;
  text-decoration: underline;
}

.pc-empty {
  padding: 2rem 1rem;
  border: 1px dashed var(--global-divider-color);
  border-radius: 10px;
  text-align: center;
}

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

html .pc-page .pc-heading {
  margin: 0.25rem 0 0.6rem;
  font-size: 1.3rem;
  font-weight: 600;
}

.pc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 21rem), 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

/* Thumbnail beside the name, then actions, text, and references. Subgrid lines the parts up across a row. */
.pc-card {
  position: relative;
  display: grid;
  grid-row: span 4;
  grid-template-rows: subgrid;
  grid-template-columns: 6.5rem minmax(0, 1fr);
  gap: 0 0.8rem;
  align-content: start;
  min-width: 0;
  padding: 0.85rem 0.9rem;
  border: 1px solid var(--global-divider-color);
  border-radius: 10px;
  background: var(--global-card-bg-color);
  scroll-margin-top: 5rem;
}

.pc-card > * {
  grid-column: 1 / -1;
}

/* Position it against the whole card, not a grid area. */
.pc-card > .pc-permalink {
  grid-column: auto;
}

.pc-card:hover {
  border-color: var(--aria-accent-border);
}

.pc-card:target {
  border-color: var(--global-theme-color);
  box-shadow: 0 0 0 2px var(--global-theme-color);
}

/* Paper figures are drawn for white paper, so the frame stays white in dark mode. */
.pc-figure {
  display: block;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid var(--global-divider-color);
  border-radius: 6px;
  background: #ffffff;
}

a.pc-figure {
  cursor: zoom-in;
}

html a.pc-figure:hover {
  border-color: var(--global-theme-color);
}

.pc-figure img {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0.25rem;
  object-fit: contain;
}

.pc-card > .pc-figure {
  grid-row: 1;
  grid-column: 1;
  align-self: start;
  aspect-ratio: 4 / 3;
}

.pc-card > .pc-head {
  grid-row: 1;
  grid-column: 2;
}

/* Most figures are wider than 4:3, so a wider frame shows them larger at the same height. */
@media (min-width: 1200px) {
  .pc-card {
    grid-template-columns: 7.5rem minmax(0, 1fr);
  }

  .pc-card > .pc-figure {
    aspect-ratio: 3 / 2;
  }
}

/* Large figures only where they leave room for the actions on the first screen. */
@media (min-width: 1200px) {
  [data-pc-featured] .pc-card {
    grid-row: span 5;
  }

  [data-pc-featured] .pc-card > .pc-figure {
    grid-column: 1 / -1;
    aspect-ratio: 5 / 2;
    margin-bottom: 0.6rem;
  }

  [data-pc-featured] .pc-card > .pc-head {
    grid-row: 2;
    grid-column: 1 / -1;
  }
}

.pc-page .pc-card p {
  margin: 0;
}

.pc-type {
  margin: 0;
  padding-right: 1.75rem;
  color: var(--global-text-color-light);
  font-size: 0.8rem;
}

html .pc-title {
  margin: 0.1rem 0;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.25;
}

html .pc-title a {
  color: var(--aria-heading-color);
}

html .pc-title a:hover {
  color: var(--global-theme-color);
}

.pc-subtitle {
  color: var(--global-text-color);
  font-size: 0.88rem;
  line-height: 1.35;
}

.pc-card .pc-links {
  align-self: start;
  margin: 0.65rem 0;
}

.pc-description {
  font-size: 0.9rem;
  line-height: 1.45;
}

ul.pc-tasks {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.55rem 0 0;
  padding: 0;
  list-style: none;
}

ul.pc-tasks li {
  margin: 0;
}

html .pc-tasks a {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 1.6rem;
  padding: 0 0.6rem;
  border: 1px solid var(--global-divider-color);
  border-radius: 1rem;
  color: var(--global-text-color);
  font-size: 0.78rem;
  text-decoration: none;
}

html .pc-tasks a i {
  color: var(--global-text-color-light);
  font-size: 0.65rem;
}

html .pc-tasks a:hover {
  border-color: var(--global-theme-color);
  color: var(--global-theme-color);
}

.pc-foot {
  align-self: end;
  padding-top: 0.6rem;
}

.pc-area,
.pc-relation {
  color: var(--global-text-color-light);
  font-size: 0.8rem;
  line-height: 1.4;
}

.pc-pubs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.5rem;
}

/* 24px is the smallest accessible touch target. */
html .pc-pubs a,
html .pc-examples a,
html .pc-header-links a {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 1.5rem;
}

html a.pc-details {
  margin-left: auto;
  font-size: 0.82rem;
}

html a.pc-details i {
  font-size: 0.7rem;
}

ul.pc-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0;
  list-style: none;
}

ul.pc-links li {
  margin: 0;
}

html a.pc-link,
.pc-no-code {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 1.85rem;
  padding: 0.12rem 0.6rem;
  border: 1px solid var(--aria-btn-border);
  border-radius: 6px;
  color: var(--aria-btn-text);
  font-size: 0.82rem;
  font-weight: 500;
  text-decoration: none;
}

html a.pc-link:hover {
  border-color: var(--global-theme-color);
  background: var(--aria-btn-hover-bg);
  color: var(--global-hover-color);
}

html a.pc-link-primary {
  border-color: var(--global-theme-color);
  background: var(--global-theme-color);
  color: var(--global-hover-text-color);
}

html a.pc-link-primary:hover {
  background: var(--global-hover-color);
  color: var(--global-hover-text-color);
}

.pc-no-code {
  border-style: dashed;
  border-color: var(--global-divider-color);
  color: var(--global-text-color-light);
  font-weight: 400;
}

html a.pc-permalink {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  display: grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--global-card-bg-color);
  color: var(--global-text-color-light);
  font-size: 0.75rem;
}

html a.pc-permalink:hover {
  border-color: var(--global-theme-color);
  color: var(--global-theme-color);
}

/* ---------- Enlarged figure ---------- */

.pc-zoom {
  max-width: min(1100px, 94vw);
  padding: 0.75rem;
  border: 0;
  border-radius: 10px;
  background: #ffffff;
  color: #1f2937;
}

.pc-zoom::backdrop {
  background: rgb(0 0 0 / 65%);
}

.pc-zoom form {
  display: flex;
  justify-content: flex-end;
}

html .pc-zoom button {
  width: 2.5rem;
  height: 2.5rem;
  border: 0;
  background: none;
  color: inherit;
  font-size: 1.1rem;
  cursor: pointer;
}

.pc-zoom img {
  display: block;
  max-width: 100%;
  max-height: 72vh;
  margin: 0 auto;
}

.pc-zoom p {
  margin: 0.75rem 0 0;
  color: inherit;
  font-size: 0.9rem;
}

.pc-toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  z-index: 1100;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  background: var(--global-text-color);
  color: var(--global-bg-color);
  font-size: 0.88rem;
  opacity: 0;
  transform: translateX(-50%);
  transition: opacity 0.15s ease;
  pointer-events: none;
}

.pc-toast.is-visible {
  opacity: 1;
}

/* ---------- List view ---------- */

.is-list .pc-grid {
  display: block;
  border-top: 1px solid var(--global-divider-color);
}

.is-list .pc-card {
  grid-template-rows: auto;
  grid-template-columns: minmax(0, 1fr) minmax(0, 30rem);
  gap: 0 1.5rem;
  padding: 0.7rem 2.5rem 0.7rem 0.25rem;
  border-width: 0 0 1px;
  border-radius: 0;
  background: none;
}

.is-list .pc-card > .pc-head {
  grid-column: 1;
}

.is-list .pc-card > .pc-links {
  grid-row: 1;
  grid-column: 2;
  align-self: center;
  margin: 0;
}

.is-list .pc-figure,
.is-list .pc-body,
.is-list .pc-area,
.is-list .pc-relation {
  display: none;
}

.is-list .pc-foot {
  padding: 0;
}

.is-list .pc-details {
  margin-left: 0.5rem;
}

/* ---------- Detail pages ---------- */

.pd-breadcrumb {
  margin-bottom: 1rem;
  color: var(--global-text-color-light);
  font-size: 0.86rem;
}

.pd-header {
  display: flex;
  align-items: center;
  gap: 2rem;
}

.pd-intro {
  flex: 1 1 0;
  min-width: 0;
}

.pd-subtitle {
  margin: 0 0 0.5rem;
  color: var(--aria-heading-color);
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.35;
}

.pd-description {
  margin: 0;
}

.pd-figure {
  flex: 0 0 42%;
  border: 1px solid var(--global-divider-color);
  border-radius: 10px;
}

.pd-resources {
  margin: 1rem 0;
}

.pd-resources :is(.pc-link, .pc-no-code) {
  min-height: 2.1rem;
  padding: 0.2rem 0.75rem;
  font-size: 0.86rem;
}

.pd-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 0.75rem 1.5rem;
  margin: 0 0 1.75rem;
  padding: 0.9rem 0;
  border: solid var(--global-divider-color);
  border-width: 1px 0;
  font-size: 0.88rem;
}

.pd-facts dt {
  color: var(--global-text-color-light);
  font-weight: 600;
}

.pd-facts dd {
  margin: 0;
}

html .pd-page article h2,
html .pd-section h2 {
  margin-top: 1.75rem;
  font-size: 1.4rem;
}

html .pd-page article h3 {
  font-size: 1.15rem;
}

.pd-section {
  margin-top: 2rem;
}

.pd-publications li {
  margin-bottom: 0.5rem;
}

.pd-authors,
.pd-annotation {
  color: var(--global-text-color-light);
  font-size: 0.86rem;
}

.pd-page table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
}

/* ---------- Small screens ---------- */

@media (max-width: 767px) {
  /* The fixed copyright bar covered a tenth of a phone screen. */
  html body:has(.pc-page, .pd-page) {
    padding-bottom: 0;
  }

  html body:has(.pc-page, .pd-page) footer.fixed-bottom {
    position: static;
  }
}

@media (max-width: 900px) {
  html .pc-header .post-title {
    font-size: 1.5rem;
  }

  .pc-header {
    margin-bottom: 0.6rem;
  }

  .pc-lede {
    font-size: 0.9rem;
    line-height: 1.4;
  }

  .pc-header-links {
    order: 2;
    margin-top: 0.35rem;
    font-size: 0.85rem;
  }

  .pc-toolbar {
    grid-template-columns: minmax(0, 1fr) auto auto;
    margin-bottom: 0.25rem;
  }

  .pc-search {
    grid-column: auto;
  }

  html .pc-more {
    display: block;
    padding: 0 0.75rem;
  }

  .pc-views {
    grid-row: 1;
    grid-column: 3;
  }

  .pc-select,
  .pc-resources {
    grid-column: 1 / -1;
  }

  .pc-toolbar:not(.is-open) :is(.pc-select, .pc-resources) {
    display: none;
  }

  html .pc-toolbar input,
  html .pc-toolbar select {
    /* 16px stops iOS from zooming in on focus. */
    font-size: 1rem;
  }

  /* One row that scrolls sideways. The faded edge shows that there is more. */
  .pc-types,
  .pc-examples {
    flex-wrap: nowrap;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(to right, #000 88%, transparent);
    mask-image: linear-gradient(to right, #000 88%, transparent);
  }

  .pc-types {
    margin: 0 -15px 0.6rem;
    padding: 2px 15px;
  }

  .pc-types::after {
    content: "";
    flex: 0 0 2.5rem;
  }

  html a.pc-type-link {
    flex: none;
  }

  .pc-examples {
    flex: 1;
  }

  html a.pc-link,
  .pc-no-code,
  html .pc-resources button,
  html button.pc-chip,
  html button.pc-clear {
    height: auto;
    min-height: 2.25rem;
    padding-inline: 0.7rem;
  }

  html .pc-tasks a {
    min-height: 2rem;
  }

  html a.pc-permalink {
    width: 2.25rem;
    height: 2.25rem;
  }

  .is-list .pc-card {
    display: block;
    padding-right: 0.25rem;
  }

  .is-list .pc-card > .pc-links {
    margin: 0.5rem 0;
  }
}

@media (max-width: 600px) {
  .pd-header {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }

  .pd-figure {
    flex: none;
  }
}

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