/* datasette-charts. Borders and washes are mixed from the page's own text
   color, so the panel follows whatever theme the page uses. */

.datasette-charts {
  --dc-line: color-mix(in srgb, currentColor 16%, transparent);
  --dc-wash: color-mix(in srgb, currentColor 5%, transparent);
  --dc-muted: color-mix(in srgb, currentColor 62%, transparent);
  --dc-accent: #2a78d6;
  margin: 1rem 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

.datasette-charts [hidden] {
  display: none !important;
}

.dc-panel > summary {
  cursor: pointer;
  padding: 0.25rem 0;
}
.dc-heading {
  font-weight: 600;
}
.dc-status {
  margin-left: 0.6rem;
  font-size: 0.85em;
  color: var(--dc-muted);
}

/* Suggestions strip: a row of cards, in rank order */
.dc-strip {
  display: flex;
  gap: 0.6rem;
  overflow-x: auto;
  padding: 0.5rem 2px 0.75rem;
  scroll-snap-type: x proximity;
}
.dc-strip:empty {
  display: none;
}
.dc-card {
  flex: 0 0 auto;
  width: 226px;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 8px;
  text-align: left;
  font: inherit;
  color: inherit;
  background: transparent;
  border: 1px solid var(--dc-line);
  border-radius: 6px;
  cursor: pointer;
  scroll-snap-align: start;
}
.dc-card:hover {
  background: var(--dc-wash);
}
.dc-card:focus-visible,
.dc-close:focus-visible,
.dc-link:focus-visible {
  outline: 2px solid var(--dc-accent);
  outline-offset: 2px;
}
.dc-card[aria-pressed="true"] {
  border-color: var(--dc-accent);
  box-shadow: 0 0 0 1px var(--dc-accent);
}
.dc-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 208px;
  height: 112px;
  overflow: hidden;
  color: var(--dc-muted);
}
.dc-thumb > svg {
  width: 40px;
  height: 40px;
}
.dc-thumb-chart {
  display: block;
  line-height: 0;
}
.dc-thumb-build {
  font-size: 2.2rem;
  font-weight: 300;
  border: 1px dashed var(--dc-line);
  border-radius: 4px;
  box-sizing: border-box;
}
.dc-card-title {
  font-weight: 600;
  font-size: 0.9em;
  line-height: 1.25;
}
.dc-card-reason {
  font-size: 0.8em;
  line-height: 1.3;
  color: var(--dc-muted);
}

/* Chart view: the chart at full size with the builder beside it */
.dc-view {
  margin-top: 0.25rem;
  padding: 0.9rem 1rem 1rem;
  border: 1px solid var(--dc-line);
  border-radius: 6px;
}
.dc-view-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}
.dc-title {
  margin: 0;
  font-size: 1.1em;
}
.dc-reason {
  margin: 0.2rem 0 0;
  font-size: 0.9em;
  color: var(--dc-muted);
}
.dc-reason:empty,
.dc-note:empty {
  display: none;
}
.dc-close,
.dc-link {
  font: inherit;
  font-size: 0.85em;
  color: inherit;
  background: transparent;
  border: 1px solid var(--dc-line);
  border-radius: 4px;
  padding: 0.15rem 0.55rem;
  cursor: pointer;
}
.dc-close:hover,
.dc-link:hover {
  background: var(--dc-wash);
}
.dc-body {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-top: 0.9rem;
}
.dc-chart-col {
  flex: 1 1 420px;
  min-width: 0;
}
/* z-index keeps tooltips that overflow the plot above the cards and
   headings around it, rather than letting those show through */
.dc-chart {
  position: relative;
  z-index: 1;
  min-height: 120px;
  transition: opacity 0.15s;
}
.dc-chart.dc-loading {
  opacity: 0.45;
}
.dc-chart figure {
  margin: 0;
}
/* Plot styles its legends with zero-specificity selectors, which any page
   stylesheet overrides, so the legend layout is restated here */
.dc-chart [class*="-swatches-wrap"] {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.2rem 1.1rem;
  min-height: 28px;
  margin: 0 0 0.4rem;
  font-size: 12px;
}
.dc-chart [class$="-swatch"] {
  display: inline-flex;
  align-items: center;
  margin: 0;
}
.dc-chart [class$="-swatch"] > svg {
  margin-right: 0.4em;
}
.dc-note {
  margin: 0.5rem 0 0;
  font-size: 0.85em;
  color: var(--dc-muted);
}
.dc-note.dc-error {
  color: inherit;
  padding: 0.5rem 0.7rem;
  background: var(--dc-wash);
  border-left: 3px solid #d03b3b;
}
.dc-links {
  margin-top: 0.75rem;
  font-size: 0.85em;
}
.dc-link-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: 0.5rem;
}
/* Manual builder */
.dc-builder {
  flex: 0 1 230px;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  font-size: 0.85em;
}
.dc-channel {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0;
  padding: 0.6rem 0 0;
  border: 0;
  border-top: 1px solid var(--dc-line);
}
.dc-field {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.dc-field > span {
  font-weight: 600;
}
.dc-field-small {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}
.dc-field-small > span {
  flex: 0 0 4.6rem;
  font-weight: 400;
  color: var(--dc-muted);
}
.dc-field select,
.dc-field input {
  font: inherit;
  color: inherit;
  min-width: 0;
  max-width: 100%;
  flex: 1 1 auto;
  box-sizing: border-box;
  padding: 0.5em 0.75em;
  border: 1px solid color-mix(in srgb, currentColor 28%, transparent);
  border-radius: 6px;
  background-color: Canvas;
}
/* Browsers draw different arrows and insets for a native select, so turn
   that off and draw a chevron to match Datasette's own filter selects. */
.dc-field select {
  appearance: none;
  cursor: pointer;
  padding-right: 2.25em;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23667085' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75em center;
  background-size: 0.75em;
}
.dc-field select:focus-visible,
.dc-field input:focus-visible {
  outline: none;
  border-color: var(--dc-accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--dc-accent) 20%, transparent);
}
.dc-check {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--dc-muted);
}

/* <datasette-chart>: one chart on its own, embedded in another page */
datasette-chart {
  display: block;
  margin: 0.5rem 0;
}
datasette-chart > .dc-title {
  font-weight: 600;
  margin-bottom: 0.5rem;
}
datasette-chart > .dc-title:empty {
  display: none;
}

/* Annotations in the builder: a list, with an editor in a dialog */
.dc-legend {
  padding: 0;
  margin-bottom: 0.15rem;
  font-weight: 600;
}
.dc-annotation-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.dc-annotation-item {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--dc-line);
  border-radius: 6px;
}
.dc-annotation-summary {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}
.dc-annotation-kind {
  overflow-wrap: anywhere;
}
.dc-annotation-text {
  color: var(--dc-muted);
  overflow-wrap: anywhere;
  white-space: pre-line;
}
.dc-annotation-actions {
  display: flex;
  gap: 0.4rem;
}
.dc-annotation-empty {
  margin: 0;
  color: var(--dc-muted);
}
.dc-annotation-add {
  align-self: flex-start;
}
.dc-link:disabled {
  opacity: 0.55;
  cursor: default;
}

/* The editor dialog, in Datasette's <datasette-modal>. It sits outside
   .datasette-charts, so it gets its own copies of the panel's colors.
   Datasette's modal styles do the rest. */
.dc-annotation-dialog {
  --dc-line: color-mix(in srgb, currentColor 16%, transparent);
  --dc-wash: color-mix(in srgb, currentColor 5%, transparent);
  --dc-muted: color-mix(in srgb, currentColor 62%, transparent);
  --dc-accent: #2a78d6;
  color: #0f0f0f;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
dialog.datasette-modal.dc-annotation-dialog {
  width: min(980px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
}
.dc-annotation-body {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem 1.5rem;
  font-size: 0.875rem;
}
.dc-annotation-form {
  flex: 1 1 260px;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.dc-annotation-preview-col {
  flex: 999 1 420px;
  min-width: 0;
}
.dc-preview-label {
  margin: 0 0 0.35rem;
  font-size: 0.8em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--dc-muted);
}
.dc-annotation-preview {
  min-height: 200px;
  padding: 0.5rem;
  border: 1px solid var(--dc-line);
  border-radius: 6px;
  background: #fff;
}
.dc-annotation-form .dc-field > label {
  font-weight: 600;
}
.dc-annotation-form [hidden] {
  display: none !important;
}
.dc-annotation-form select,
.dc-annotation-form input:not([type="checkbox"]),
.dc-annotation-form textarea {
  font: inherit;
  color: inherit;
  width: 100%;
  box-sizing: border-box;
  padding: 0.5em 0.75em;
  border: 1px solid color-mix(in srgb, currentColor 28%, transparent);
  border-radius: 6px;
  background-color: Canvas;
}
.dc-annotation-form textarea {
  resize: vertical;
  min-height: 4.5em;
}
.dc-annotation-form select {
  appearance: none;
  cursor: pointer;
  padding-right: 2.25em;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23667085' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75em center;
  background-size: 0.75em;
}
.dc-annotation-form :is(select, input, textarea):focus-visible {
  outline: none;
  border-color: var(--dc-accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--dc-accent) 20%, transparent);
}
.dc-annotation-form [aria-invalid="true"] {
  border-color: #d03b3b;
}
.dc-annotation-dialog .dc-check input:focus-visible,
.dc-annotation-dialog .modal-btn:focus-visible {
  outline: 2px solid var(--dc-accent);
  outline-offset: 2px;
}
.dc-combo {
  display: block;
}
.dc-hint {
  font-size: 0.85em;
  color: var(--dc-muted);
}
.dc-dialog-error {
  margin: 0;
  color: #b42318;
}
.dc-dialog-error:empty {
  display: none;
}
.dc-annotation-dialog .dc-note {
  margin: 0.5rem 0 0;
  font-size: 0.85em;
  color: var(--dc-muted);
}
.dc-annotation-dialog .dc-note:empty {
  display: none;
}
.dc-annotation-form .dc-field > .dc-hint {
  font-weight: 400;
}
/* Shown when the clipboard cannot be used, to copy by hand */
.dc-copy-fallback {
  flex: 1 1 100%;
  min-width: 0;
  font: inherit;
  font-size: 0.95em;
  color: inherit;
  padding: 0.35em 0.5em;
  border: 1px solid color-mix(in srgb, currentColor 28%, transparent);
  border-radius: 4px;
  background-color: Canvas;
}

/* The numbered key under a chart whose callouts did not fit beside it */
.dc-annotation-key {
  list-style: none;
  margin: 0.4rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 12px;
  line-height: 1.35;
}
.dc-annotation-key li {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
}
.dc-annotation-key-number {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-top: 0.5px;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  forced-color-adjust: none;
}
/* A note that had no room on the plot */
.dc-annotation-caption {
  margin: 0.35rem 0 0;
  font-size: 12px;
  line-height: 1.4;
  color: var(--dc-muted, inherit);
}
