/* The MyJS library: /download, its permalinks, block pages (/library/{name})
   and the dialogs the admin's block editor shares with them. */

/* ---------- Dialogs ---------- */

.lib-dialog {
  width: min(960px, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-raised);
  color: var(--text);
  box-shadow: 0 20px 60px var(--shadow);
}

.lib-dialog[open] {
  display: flex;
  flex-direction: column;
}

.lib-dialog::backdrop {
  background: rgb(0 0 0 / 0.55);
}

.lib-dialog-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.lib-dialog-head h2 {
  margin: 0;
  font-size: 1.05rem;
}

.lib-dialog-head .muted {
  overflow: hidden;
  font-size: 0.82rem;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.lib-dialog-close {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  margin-left: auto;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  cursor: pointer;
}

.lib-dialog-close:hover {
  background: var(--bg-sunken);
  color: var(--text);
}

.lib-dialog-close svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.lib-dialog-body {
  overflow: auto;
  padding: 1rem 1.25rem;
}

.lib-dialog-foot {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
}

.lib-source {
  overflow: auto;
  margin: 0;
  padding: 1rem;
  background: var(--bg-sunken);
  font: 0.85rem/1.55 var(--mono);
  tab-size: 2;
}

/* Syntax highlighting (highlight.js classes), in the same colors as the JSDoc viewer */
.lib-source {
  --hl-keyword: #c792ea;
  --hl-string: #c3e88d;
  --hl-number: #f78c6c;
  --hl-title: #82aaff;
  --hl-comment: #7f879a;
  --hl-built-in: #ffcb6b;
  --hl-regexp: #89ddff;
}

@media (prefers-color-scheme: light) {
  .lib-source {
    --hl-keyword: #a626a4;
    --hl-string: #2f6b22;
    --hl-number: #8a5300;
    --hl-title: #2f5bd3;
    --hl-comment: #5d626c;
    --hl-built-in: #8a5300;
    --hl-regexp: #b3261e;
  }
}

.lib-source :is(.hljs-keyword, .hljs-literal, .hljs-variable.language_) { color: var(--hl-keyword); }
.lib-source :is(.hljs-string, .hljs-template-tag, .hljs-template-variable) { color: var(--hl-string); }
.lib-source :is(.hljs-number, .hljs-attr, .hljs-property) { color: var(--hl-number); }
.lib-source :is(.hljs-title, .hljs-title.function_, .hljs-title.class_) { color: var(--hl-title); }
.lib-source :is(.hljs-comment, .hljs-meta) { color: var(--hl-comment); font-style: italic; }
.lib-source :is(.hljs-built_in, .hljs-type) { color: var(--hl-built-in); }
.lib-source :is(.hljs-regexp, .hljs-subst) { color: var(--hl-regexp); }
.lib-source .hljs-doctag { color: var(--hl-keyword); font-style: normal; }

.lib-source-dialog .lib-source {
  flex: 1;
  min-height: 0;
}

/* Testing a block and viewing docs: nearly the whole screen, with a gap
   around it (and the page dimmed behind) so it's clearly not a new page */
.lib-try-dialog {
  width: calc(100vw - 3rem);
  max-width: none;
  height: calc(100vh - 3rem);
  height: calc(100dvh - 3rem);
  max-height: none;
  margin: auto;
}

.lib-try {
  flex: 1;
  min-height: 0;
}

.lib-license {
  margin: 1.5rem 0 0.5rem;
  border-radius: 10px;
}

.lib-pad-frame {
  display: block;
  width: 100%;
  border: 0;
}

.lib-docs-view {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--bg);
}

.lib-try-note {
  padding: 1rem 1.25rem;
  color: var(--muted);
}

.lib-try-error {
  padding: 1rem 1.25rem;
  color: var(--danger-text);
}

/* The /jsdocs viewer, loaded out of sight to make the docs for downloads */
.lib-docs-frame {
  position: fixed;
  top: 0;
  left: -10000px;
  width: 1200px;
  height: 800px;
  border: 0;
  visibility: hidden;
}

/* ---------- Shared bits ---------- */

.lib-hint {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.lib-hint.is-error,
.lib-status.is-error {
  color: var(--danger-text);
}

.lib-tag {
  display: inline-block;
  padding: 0.05rem 0.5rem;
  border-radius: 999px;
  background: var(--bg-sunken);
  color: var(--muted);
  font-size: 0.75rem;
}

.lib-chip {
  display: inline-block;
  margin: 0 0.25rem 0.3rem 0;
  padding: 0.15rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-sunken);
  font-size: 0.88rem;
}

a.lib-chip {
  color: var(--text);
  text-decoration: none;
}

a.lib-chip:hover {
  border-color: var(--accent-text);
}

.lib-conflicts {
  margin: 1rem 0;
  padding: 0.75rem 1rem;
  border: 1px solid rgb(255 110 100 / 0.45);
  border-radius: 10px;
  background: rgb(255 110 100 / 0.08);
  font-size: 0.9rem;
}

.lib-conflicts p {
  margin: 0 0 0.35rem;
}

.lib-conflicts ul {
  margin: 0;
  padding-left: 1.2rem;
}

.lib-loops {
  margin: 0.75rem 0;
  color: var(--warning-text);
  font-size: 0.85rem;
}

/* ---------- /download and permalinks ---------- */

.lib-layout {
  display: grid;
  grid-template-columns: 1fr minmax(280px, 340px);
  gap: 1.5rem;
  align-items: start;
}

.lib-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.lib-toolbar input,
.lib-toolbar select,
.lib-name-row select,
.lib-name-row input {
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-sunken);
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
}

.lib-search {
  flex: 1 1 220px;
}

.lib-view-toggle {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.lib-view-toggle button {
  padding: 0.45rem 0.9rem;
  border: 0;
  background: var(--bg-sunken);
  color: var(--muted);
  font: 600 0.88rem var(--font);
  cursor: pointer;
}

.lib-view-toggle button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--on-accent);
}

.lib-list-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}

.lib-count {
  margin: 0 0 0.5rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.lib-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-raised);
}

.lib-list:empty {
  display: none;
}

.lib-item {
  padding: 0.8rem 1rem;
  border-top: 1px solid var(--border);
}

.lib-item:first-child {
  border-top: 0;
}

.lib-item.is-picked {
  background: color-mix(in srgb, var(--accent) 7%, transparent);
}

.lib-item.is-required {
  background: color-mix(in srgb, var(--info-text) 7%, transparent);
}

.lib-item-main {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.6rem;
  cursor: pointer;
}

.lib-item-main input {
  width: 1.05rem;
  height: 1.05rem;
  margin: 0;
  align-self: center;
  accent-color: var(--accent);
}

.lib-item-main input:disabled {
  cursor: not-allowed;
}

.lib-item-name {
  font-weight: 700;
}

.lib-item-version {
  color: var(--muted);
  font-size: 0.82rem;
}

.lib-item-environments {
  color: var(--muted);
  font-size: 0.78rem;
}

.lib-environments {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.lib-environments.is-warning {
  color: var(--warning-text);
}

.lib-item-category {
  margin-left: auto;
  color: var(--accent-text);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.lib-item p {
  margin: 0.35rem 0 0 1.65rem;
}

.lib-item-description {
  color: var(--muted);
  font-size: 0.92rem;
}

.lib-item-exports code {
  margin-right: 0.15rem;
  font-size: 0.84rem;
}

.lib-item-required {
  color: var(--info-text);
  font-size: 0.85rem;
}

.lib-item-links {
  font-size: 0.85rem;
}

.lib-export-item .lib-item-main .muted {
  font-size: 0.88rem;
}

.lib-summary {
  position: sticky;
  top: 5rem;
  padding: 1.1rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-raised);
}

.lib-summary h2 {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
}

.lib-summary-text {
  margin: 0 0 0.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.lib-picked {
  margin: 0 0 0.75rem;
  padding: 0;
  list-style: none;
  font-size: 0.9rem;
}

.lib-picked li {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0;
}

.lib-picked .is-required .lib-picked-name {
  color: var(--muted);
}

.lib-unpick {
  margin-left: auto;
  padding: 0 0.4rem;
  border: 0;
  border-radius: 4px;
  background: none;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.lib-unpick:hover {
  background: var(--bg-sunken);
  color: var(--danger-text);
}

.lib-options {
  margin: 1rem 0;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.lib-option {
  margin: 0 0 0.9rem;
  padding: 0;
  border: 0;
}

.lib-option-label {
  display: block;
  margin-bottom: 0.35rem;
  padding: 0;
  font-size: 0.88rem;
  font-weight: 600;
}

.lib-name-row {
  display: flex;
  gap: 0.4rem;
}

.lib-name-row input {
  flex: 1;
  min-width: 0;
}

.lib-radio {
  display: block;
  font-size: 0.92rem;
}

.lib-radio small {
  color: var(--muted);
}

.lib-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.lib-actions .link-button {
  align-self: flex-start;
}

.lib-view-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
}

.lib-actions button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.lib-actions .link-button,
.lib-list-head .link-button {
  font-size: 0.9rem;
}

.lib-status {
  min-height: 1.2em;
  margin: 0.75rem 0 0;
  font-size: 0.85rem;
}

.lib-permalink {
  margin: 0.5rem 0 0;
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}

.lib-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-raised);
  font-size: 0.92rem;
}

.lib-table th,
.lib-table td {
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.lib-table th {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.lib-table-exports {
  font-size: 0.85rem;
}

/* ---------- Block pages ---------- */

.lib-version-pill {
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  background: var(--bg-sunken);
  color: var(--muted);
  font-size: 0.5em;
  font-weight: 500;
  vertical-align: middle;
}

.lib-facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.6rem 1.25rem;
  margin: 0 0 2rem;
}

.lib-facts dt {
  padding-top: 0.2rem;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
}

.lib-facts dd {
  margin: 0;
}

.lib-block-page .container > h2 {
  margin: 2rem 0 0.5rem;
}

.lib-example {
  margin: 1.25rem 0;
}

.lib-example h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

.lib-example-code {
  border-radius: 10px;
}

.lib-example-pad {
  min-height: 150px;
}

.lib-code-details {
  margin: 2rem 0 0;
}

.lib-code-details summary {
  color: var(--accent-text);
  font-weight: 600;
  cursor: pointer;
}

.lib-code-details .lib-source {
  margin-top: 0.75rem;
  border-radius: 10px;
  max-height: 70vh;
}

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

.lib-versions li {
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}

.lib-versions-head {
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
}

.lib-versions p {
  margin: 0.3rem 0 0;
  font-size: 0.92rem;
}

@media (max-width: 820px) {
  .lib-layout {
    grid-template-columns: 1fr;
  }

  .lib-summary {
    position: static;
  }
}
