/* TemplateFlow gallery. Colours come from Material's palette variables (light and dark). */

.md-main__inner.md-grid:has(.tfg-profile),
.md-main__inner.md-grid:has(.tfg-gallery) {
  max-width: min(100rem, 100%);
}

.tfg {
  --tfg-radius: 0.4rem;
  --tfg-border: var(--md-default-fg-color--lightest);
  /* Darker than Material's --md-default-fg-color--light: small text must reach 4.5:1 */
  --tfg-muted: color-mix(in srgb, var(--md-default-fg-color) 75%, transparent);
  --tfg-accent: var(--md-accent-fg-color);
  --tfg-stage-h: clamp(22rem, 62vh, 44rem);
  --tfg-mni: #8fb0e3;
  --tfg-other: #a6a6a6;
}

.md-typeset .tfg ul.tfg-perms,
.md-typeset .tfg ul.tfg-facts,
.md-typeset .tfg ul.tfg-file-list,
.md-typeset .tfg ol.tfg-layers__list,
.md-typeset .tfg ul.tfg-readout__values {
  list-style: none;
  margin: 0;
  padding: 0;
}
.md-typeset .tfg ul.tfg-perms > li,
.md-typeset .tfg ul.tfg-facts > li,
.md-typeset .tfg ul.tfg-file-list > li,
.md-typeset .tfg ol.tfg-layers__list > li,
.md-typeset .tfg ul.tfg-readout__values > li {
  margin: 0;
}

/* Material styles every <details> as a collapsible admonition: undo that for ours */
.md-typeset .tfg details {
  border: 0;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  margin: 0;
  font-size: inherit;
  overflow: visible;
}
.md-typeset .tfg details > summary {
  background: none;
  border: 0;
  margin: 0;
  min-height: 0;
  padding: 0.3em 0.2em 0.3em 1.1em;
  font-weight: inherit;
  position: relative;
}
.md-typeset .tfg details > summary::before {
  content: '\25b8';
  -webkit-mask-image: none;
  mask-image: none;
  background: none;
  position: absolute;
  left: 0.2em;
  top: 0.3em;
  width: auto;
  height: auto;
  transform: none;
  color: var(--tfg-muted);
}
.md-typeset .tfg details[open] > summary::before { content: '\25be'; }
.md-typeset .tfg details > summary::after { display: none; }
.md-typeset .tfg details > summary::-webkit-details-marker { display: none; }

.md-typeset .tfg h1.tfg-head__id { color: var(--md-default-fg-color); }

.tfg-offscreen { position: fixed; left: -9999px; }
/* Material fades every <small> (opacity .75): our muted colour already accounts for it */
.md-typeset .tfg small { opacity: 1; }
.tfg-muted, .tfg-hint { color: var(--tfg-muted); }
.tfg-hint { font-size: 0.75rem; }
.tfg-error { color: #c62828; }
.tfg-note {
  display: inline-block;
  border-left: 3px solid #f9a825;
  padding-left: 0.5em;
}
.tfg-banner {
  background: #fff3cd;
  color: #5c4400;
  border: 1px solid #f0d68a;
  border-radius: var(--tfg-radius);
  padding: 0.5em 0.8em;
}
.tfg-sep { margin: 0 0.4em; color: var(--tfg-muted); }
.tfg-k {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--tfg-muted);
  margin-right: 0.3em;
}
.md-typeset .tfg-h3 { font-size: 0.9rem; margin: 0 0 0.4em; font-weight: 700; }

/* Links in running text must not rely on colour alone */
.md-typeset .tfg :is(p, li, dd, figcaption, .tfg-cite) a:not(.tfg-btn) {
  text-decoration: underline;
  text-decoration-thickness: from-font;
  text-underline-offset: 0.15em;
}

/* Buttons -------------------------------------------------------------------------- */
.tfg-btn, .tfg-icon, .tfg-tag, .tfg-chip, .tfg-link, .tfg-seg button {
  font: inherit;
  cursor: pointer;
  color: inherit;
  background: none;
}
.tfg-btn {
  border: 1px solid var(--tfg-border);
  border-radius: var(--tfg-radius);
  padding: 0.25em 0.7em;
  font-size: 0.75rem;
}
.tfg-btn:hover, .tfg-btn:focus-visible { border-color: var(--tfg-accent); color: var(--tfg-accent); }
.tfg-btn--small { font-size: 0.65rem; padding: 0.1em 0.5em; vertical-align: middle; }
.tfg-btn--primary {
  background: var(--md-primary-fg-color);
  color: var(--md-primary-bg-color);
  border-color: transparent;
}
.tfg-btn--primary:hover { color: var(--md-primary-bg-color); opacity: 0.9; }
.tfg-btn.is-done, .tfg-tag.is-done { color: #2e7d32; border-color: #2e7d32; }
.tfg-link { border: 0; padding: 0; color: var(--md-typeset-a-color); text-decoration: underline; }
.tfg-icon {
  border: 1px solid transparent;
  border-radius: 0.25rem;
  width: 1.5rem;
  height: 1.5rem;
  line-height: 1;
  padding: 0;
}
.tfg-icon:hover:not(:disabled) { border-color: var(--tfg-border); color: var(--tfg-accent); }
.tfg-icon:disabled { opacity: 0.3; cursor: default; }
.tfg-icon--add { font-weight: 700; font-size: 0.95rem; }
.tfg-tag {
  border: 1px solid var(--tfg-border);
  border-radius: 0.2rem;
  font-size: 0.6rem;
  padding: 0 0.35em;
  line-height: 1.5;
  font-family: var(--md-code-font-family);
}
.tfg-tag--warn { border-style: dashed; }
.tfg-tag:hover { border-color: var(--tfg-accent); color: var(--tfg-accent); }
.tfg-chip {
  border: 1px solid var(--tfg-border);
  border-radius: 1rem;
  padding: 0.05em 0.6em;
  margin: 0 0.2em 0.3em 0;
  font-size: 0.7rem;
}
.tfg-chip:hover { border-color: var(--tfg-accent); }

/* License badges ------------------------------------------------------------------- */
.tfg-lic {
  display: inline-block;
  border-radius: 0.25rem;
  padding: 0.1em 0.55em;
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  background: #757575;
  white-space: nowrap;
  vertical-align: middle;
}
.tfg-lic--public-domain { background: #2e7d32; }
.tfg-lic--permissive { background: #00796b; }
.tfg-lic--attribution { background: #1565c0; }
.tfg-lic--share-alike { background: #6a1b9a; }
.tfg-lic--noncommercial { background: #bf360c; }
.tfg-lic--unreviewed { background: #757575; }
.tfg-lic-button {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  border: 1px solid var(--tfg-border);
  border-radius: var(--tfg-radius);
  padding: 0.3em 0.6em;
  background: none;
  color: inherit;
  cursor: pointer;
  font: inherit;
}
.tfg-lic-button:hover { border-color: var(--tfg-accent); }
.tfg-lic-button .tfg-lic { font-size: 0.85rem; }
.tfg-lic-button__k { font-size: 0.7rem; text-transform: uppercase; color: var(--tfg-muted); }
.tfg-perms { display: flex; flex-wrap: wrap; gap: 0.2em 0.8em; font-size: 0.7rem; margin-top: 0.35em !important; }
.tfg-perms .is-yes { color: #2e7d32; }
.tfg-perms .is-no { color: #c62828; }
.tfg-perms .is-req { color: var(--tfg-muted); }
[data-md-color-scheme="slate"] .tfg-perms .is-yes { color: #81c784; }
[data-md-color-scheme="slate"] .tfg-perms .is-no { color: #ef9a9a; }

/* Profile header ------------------------------------------------------------------- */
.tfg-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.8rem 2rem;
}
.md-typeset .tfg-head__id { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
.md-typeset .tfg-head__name { margin: 0.2em 0 0; font-size: 1rem; color: var(--tfg-muted); }
.md-typeset .tfg-crumbs { margin: 0 0 0.3em; font-size: 0.75rem; }
.tfg-head__license { max-width: 28rem; }
.tfg-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3em 1.6em;
  margin: 0.9rem 0 1rem !important;
  font-size: 0.8rem;
}

/* Workspace: viewer + files -------------------------------------------------------- */
.tfg-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(17rem, 25rem);
  gap: 1rem;
  align-items: start;
}
@media (max-width: 60em) {
  .tfg-workspace { grid-template-columns: minmax(0, 1fr); }
}
.tfg-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.8rem;
  margin-bottom: 0.5rem;
  font-size: 0.75rem;
}
.tfg-seg { display: inline-flex; border: 1px solid var(--tfg-border); border-radius: var(--tfg-radius); overflow: hidden; }
.tfg-seg button { border: 0; padding: 0.3em 0.7em; font-size: 0.75rem; }
.tfg-seg button + button { border-left: 1px solid var(--tfg-border); }
.tfg-seg button[aria-pressed="true"] { background: var(--md-primary-fg-color); color: var(--md-primary-bg-color); }
.tfg-variant select, .tfg-ctl select, .tfg-ctl input[type="number"] {
  font: inherit;
  color: inherit;
  background: var(--md-default-bg-color);
  border: 1px solid var(--tfg-border);
  border-radius: 0.25rem;
  padding: 0.1em 0.3em;
}
.tfg-stage {
  position: relative;
  height: var(--tfg-stage-h);
  background: #000;
  border-radius: var(--tfg-radius);
  overflow: hidden;
  outline: 2px solid transparent;
  transition: outline-color 0.15s;
}
.tfg-stage.is-over { outline-color: var(--tfg-accent); }
.tfg-canvas { display: block; width: 100%; height: 100%; }
.tfg-stage__msg {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  align-items: center;
  justify-content: center;
  color: #ddd;
  background: rgba(0, 0, 0, 0.55);
  text-align: center;
  padding: 1rem;
  font-size: 0.8rem;
}
.tfg-stage__msg[hidden] { display: none; }
.tfg-stage__drop {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.4);
  pointer-events: none;
}
.tfg-stage.is-over .tfg-stage__drop { display: flex; }
.tfg-stage__tip {
  position: absolute;
  pointer-events: none;
  max-width: 216px;
  padding: 0.25em 0.55em;
  border-radius: 0.25rem;
  background: rgba(20, 20, 20, 0.85);
  color: #fff;
  font-size: 0.7rem;
  line-height: 1.35;
  box-shadow: 0 0.1rem 0.4rem rgba(0, 0, 0, 0.4);
}
.tfg-stage__tip[hidden] { display: none; }
.tfg-stage__actions { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; margin: 0; }
.tfg-stage__msg .tfg-btn:not(.tfg-btn--primary) { color: #eee; border-color: rgba(255, 255, 255, 0.4); }
.tfg-only-touch { display: none; }
@media (hover: none) and (pointer: coarse) {
  .tfg-only-touch { display: block; }
  .tfg-only-pointer { display: none; }
}
.tfg-readout {
  font-family: var(--md-code-font-family);
  font-size: 0.7rem;
  margin: 0.5rem 0;
  min-height: 2.6em;
}
.tfg-readout__values { display: flex; flex-wrap: wrap; gap: 0.1em 1.2em; margin-top: 0.2em !important; }
.tfg-readout__layer { color: var(--tfg-muted); }
.tfg-readout__label { color: var(--md-typeset-a-color); font-weight: 700; }
.tfg-readout__kind {
  font-family: var(--md-text-font-family);
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--tfg-muted);
  margin-right: 0.3em;
}

.tfg-layers { margin-top: 0.4rem; }
.tfg-layer {
  border: 1px solid var(--tfg-border);
  border-radius: var(--tfg-radius);
  padding: 0.35rem 0.5rem;
  margin-bottom: 0.35rem !important;
  font-size: 0.72rem;
}
.tfg-layer__head { display: flex; align-items: center; gap: 0.5em; }
.tfg-layer__name { font-family: var(--md-code-font-family); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.tfg-layer__role { font-size: 0.62rem; text-transform: uppercase; color: var(--tfg-muted); }
.tfg-layer__tools { display: inline-flex; gap: 0.1em; }
.tfg-layer__controls { display: flex; flex-wrap: wrap; gap: 0.3em 1em; margin-top: 0.25em; align-items: center; }
.tfg-ctl { display: inline-flex; align-items: center; gap: 0.3em; color: var(--tfg-muted); }
.tfg-ctl input[type="range"] { width: 7rem; accent-color: var(--md-primary-fg-color); }
.tfg-ctl input[type="number"] { width: 5rem; }
.tfg-ctl--wide input[type="range"] { width: 12rem; }
.tfg-frame-name { color: var(--md-default-fg-color); font-family: var(--md-code-font-family); }

.tfg-files {
  border: 1px solid var(--tfg-border);
  border-radius: var(--tfg-radius);
  display: flex;
  flex-direction: column;
  max-height: calc(var(--tfg-stage-h) + 12rem);
}
.tfg-files__head { padding: 0.6rem 0.7rem 0.4rem; border-bottom: 1px solid var(--tfg-border); }
.tfg-files__head small { font-weight: 400; color: var(--tfg-muted); }
.tfg-files__filter {
  width: 100%;
  font: inherit;
  font-size: 0.75rem;
  color: inherit;
  background: var(--md-default-bg-color);
  border: 1px solid var(--tfg-border);
  border-radius: 0.25rem;
  padding: 0.3em 0.5em;
}
.tfg-files__list { overflow: auto; padding: 0.3rem 0.4rem 0.6rem; font-size: 0.72rem; }
.tfg-sec > summary, .tfg-family > summary { cursor: pointer; padding: 0.3em 0.2em; }
.tfg-sec > summary { font-weight: 700; }
.tfg-sec > summary small, .tfg-family > summary small { color: var(--tfg-muted); font-weight: 400; }
.tfg-sec--atlases {
  border-left: 3px solid var(--tfg-accent);
  background: color-mix(in srgb, var(--tfg-accent) 7%, transparent);
  border-radius: 0 var(--tfg-radius) var(--tfg-radius) 0;
  padding: 0 0.3em 0.2em 0.4em;
  margin: 0.2em 0;
}
.tfg-family { margin-left: 0.4em; }
.tfg-family.is-flash > summary { background: color-mix(in srgb, var(--tfg-accent) 25%, transparent); }
.tfg-family__name { color: var(--tfg-muted); margin-left: 0.4em; font-size: 0.68rem; }
.tfg-family__meta { color: var(--tfg-muted); font-size: 0.68rem; margin: 0 0 0.3em 1em; }
.md-typeset .tfg-family__meta p { margin: 0.2em 0; }
.tfg-file {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.4em;
  padding: 0.12em 0.25em;
  border-radius: 0.2rem;
}
.tfg-file[draggable="true"] { cursor: grab; }
.tfg-file:hover { background: var(--md-default-fg-color--lightest); }
.tfg-file.is-missing .tfg-file__name { color: var(--tfg-muted); text-decoration: line-through; }
.tfg-file.is-missing .tfg-file__size { color: #c62828; }
.tfg-file.is-loaded .tfg-file__name { color: var(--md-typeset-a-color); font-weight: 700; }
.tfg-file__name { font-family: var(--md-code-font-family); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tfg-file__size { color: var(--tfg-muted); font-size: 0.65rem; white-space: nowrap; }
.tfg-file__actions { display: inline-flex; gap: 0.2em; align-items: center; }

/* Sections below the viewer -------------------------------------------------------- */
.tfg-tabs {
  display: flex;
  gap: 1.5rem;
  margin: 1.6rem 0 0.4rem;
  border-bottom: 1px solid var(--tfg-border);
  font-size: 0.8rem;
  position: sticky;
  top: 2.4rem;
  background: var(--md-default-bg-color);
  z-index: 1;
}
.tfg-tabs a { padding: 0.5em 0; }
.tfg-section { scroll-margin-top: 5rem; }
.tfg-dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 0.4em 1.2em; }
.md-typeset .tfg-dl dd { margin: 0; }
.tfg-dl dt { font-weight: 700; color: var(--tfg-muted); }
.tfg-table-wrap { overflow-x: auto; }
.md-typeset .tfg-table { border-collapse: collapse; font-size: 0.72rem; }
.md-typeset .tfg-table th, .md-typeset .tfg-table td {
  border-bottom: 1px solid var(--tfg-border);
  padding: 0.3em 0.8em 0.3em 0;
  text-align: left;
  vertical-align: top;
}
.tfg-pre {
  white-space: pre-wrap;
  font-size: 0.7rem;
  max-height: 60vh;
  overflow: auto;
  background: var(--md-code-bg-color);
  padding: 0.6em 0.8em;
  border-radius: var(--tfg-radius);
}
.tfg-details summary { cursor: pointer; }
.md-typeset .tfg-refs li { margin-bottom: 0.5em; }
.tfg-cite {
  border: 1px solid var(--tfg-border);
  border-left: 3px solid var(--md-primary-fg-color);
  border-radius: var(--tfg-radius);
  padding: 0.2rem 1rem 0.6rem;
  margin-top: 1.2rem;
}
.tfg-code { position: relative; }
.tfg-code > .tfg-btn { position: absolute; top: 0.4rem; right: 0.4rem; z-index: 1; }
.md-typeset .tfg-code pre { margin-top: 0.3em; }
.md-typeset .tfg-code pre > code { padding-right: 4rem; }

/* Dialogs -------------------------------------------------------------------------- */
.tfg-dialog {
  max-width: min(56rem, 94vw);
  width: 100%;
  border: 1px solid var(--tfg-border);
  border-radius: 0.5rem;
  background: var(--md-default-bg-color);
  color: var(--md-default-fg-color);
  padding: 1rem 1.2rem;
}
.tfg-dialog--small { max-width: 26rem; }
/* Not a heading element: dialogs must not become search sections */
.md-typeset .tfg-dialog__title { font-size: 1rem; font-weight: 700; margin: 0 0 0.6em; overflow-wrap: anywhere; }
.tfg-dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
.tfg-dialog__close { float: right; }
.tfg-dialog__close button { font-size: 1.3rem; background: none; border: 0; color: inherit; cursor: pointer; }
.tfg-confirm__actions { display: flex; justify-content: flex-end; gap: 0.6rem; }

/* Gallery -------------------------------------------------------------------------- */
.tfg-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 1rem;
  margin: 0.8rem 0 1.2rem;
  font-size: 0.75rem;
}
.tfg-filters input[type="search"] {
  flex: 1 1 16rem;
  font: inherit;
  font-size: 0.8rem;
  color: inherit;
  background: var(--md-default-bg-color);
  border: 1px solid var(--tfg-border);
  border-radius: var(--tfg-radius);
  padding: 0.4em 0.6em;
}
.tfg-filters select {
  font: inherit;
  color: inherit;
  background: var(--md-default-bg-color);
  border: 1px solid var(--tfg-border);
  border-radius: 0.25rem;
  margin-left: 0.3em;
}
.tfg-check { display: inline-flex; align-items: center; gap: 0.3em; }
.tfg-count { color: var(--tfg-muted); margin-left: auto; }
.tfg-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(12.5rem, 1fr));
  gap: 1rem;
}
.tfg-card[hidden] { display: none; }
.tfg-card__link {
  display: flex;
  flex-direction: column;
  height: 100%;
  border: 1px solid var(--tfg-border);
  border-radius: 0.6rem;
  overflow: hidden;
  color: inherit !important;
  transition: border-color 0.15s, transform 0.15s;
}
.tfg-card__link:hover, .tfg-card__link:focus-visible { border-color: var(--tfg-accent); transform: translateY(-2px); }
.tfg-card__thumb { display: block; aspect-ratio: 1; background: #000; }
.tfg-card__thumb img { display: block; width: 100%; height: 100%; object-fit: contain; }
.tfg-card__body { display: flex; flex-direction: column; gap: 0.25em; padding: 0.6rem 0.7rem 0.7rem; font-size: 0.72rem; }
.tfg-card__body .tfg-lic { align-self: flex-start; margin-top: 0.3em; }
.tfg-card__id { font-size: 0.85rem; overflow-wrap: anywhere; }
.tfg-card__name { color: var(--tfg-muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tfg-card__meta { color: var(--tfg-muted); }

/* Home-page mosaic (the TemplateFlow templates figure) ------------------------------ */
.md-typeset .tfg-mosaic { margin: 1rem 0 1.6rem; }
.tfg-mosaic__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(6.5rem, 1fr));
  gap: 0.45rem;
}
.tfg-tile {
  display: grid;
  grid-template-columns: 1.3rem minmax(0, 1fr);
  align-items: center;
  background: var(--tfg-other);
  border-radius: 0.8rem;
  padding: 0.3rem 0.3rem 0.3rem 0;
  color: #111 !important;
  transition: transform 0.15s, box-shadow 0.15s;
}
.tfg-tile--mni { background: var(--tfg-mni); }
.tfg-tile:hover, .tfg-tile:focus-visible { transform: scale(1.03); box-shadow: 0 0.2rem 0.6rem rgba(0, 0, 0, 0.35); }
.tfg-tile__label {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  justify-self: center;
  font-size: 0.68rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-height: 100%;
}
.tfg-tile img { display: block; width: 100%; aspect-ratio: 1; object-fit: contain; background: #000; border-radius: 0.55rem; }
.md-typeset .tfg-mosaic figcaption { max-width: none; font-size: 0.72rem; color: var(--tfg-muted); margin-top: 0.6rem; }
.tfg-legend::before {
  content: '';
  display: inline-block;
  width: 0.8em;
  height: 0.8em;
  border-radius: 0.2em;
  margin-right: 0.3em;
  vertical-align: -0.1em;
}
.tfg-legend { margin-right: 1em; }
.tfg-legend--mni::before { background: var(--tfg-mni); }
.tfg-legend--other::before { background: var(--tfg-other); }
