/* Styles of the settings panel (demos/settings.html), on top of cookbook.css. */
@import "cookbook.css";

:root {
  --sidebar-width: 30rem;
}

body {
  --panel-border: var(--hr-color);
  --panel-muted: var(--text-color-muted);
  --panel-accent: var(--link-color);
  --control-bg: #f4f6f9;
  --control-border: #c3ccd7;
  --focus: rgba(42, 109, 176, 0.35);
  --error: #c92a2a;
  --mark: #ffe066;
  color-scheme: light;
}

body.dark {
  --control-bg: hsl(207, 23%, 22%);
  --control-border: hsl(207, 15%, 35%);
  --focus: rgba(131, 191, 251, 0.4);
  --error: #ff8787;
  --mark: #b08800;
  color-scheme: dark;
}

/* The controls set display, which would override the hidden attribute. */
[hidden] {
  display: none !important;
}

#sidebar h1 {
  margin-right: 3.6rem;
}

#panel[inert] {
  opacity: 0.5;
}

.tools {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--panel-border);
  background: var(--background-color);
}

.tools input[type="search"] {
  width: 100%;
}

.intro {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  color: var(--panel-muted);
}

/* Sections. */
.section {
  padding: 0.25rem 0 0.75rem;
  border-bottom: 1px solid var(--panel-border);
  scroll-margin-top: 3.5rem;
}

.section > summary {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0;
  list-style: none;
  cursor: pointer;
  user-select: none;
}

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

.section > summary::before {
  content: "";
  flex: none;
  width: 0.4em;
  height: 0.4em;
  border: solid var(--panel-muted);
  border-width: 0 2px 2px 0;
  transform: rotate(-45deg);
  transition: transform 0.15s;
}

.section[open] > summary::before {
  transform: rotate(45deg);
}

#panel h2 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.4;
  font-weight: 600;
}

#panel h3 {
  margin: 0 0 0.25rem;
  font-size: 0.85rem;
  line-height: 1.4;
  font-weight: 600;
}

#panel .description {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  line-height: 1.4;
  color: var(--panel-muted);
}

mark {
  padding: 0 1px;
  border-radius: 2px;
  background: var(--mark);
  color: inherit;
}

/* Controls. theme.css styles all inputs, and most of that does not suit a compact panel. */
#sidebar input,
#sidebar select,
#sidebar button {
  font-size: 0.85rem;
  color: inherit;
  box-shadow: none;
}

#sidebar input[type="text"],
#sidebar input[type="number"],
#sidebar input[type="search"],
#sidebar select {
  min-width: 0;
  padding: 0.2rem 0.4rem;
  border: 1px solid var(--control-border);
  border-radius: 0.3rem;
  background: var(--control-bg);
}

#sidebar input:focus-visible,
#sidebar select:focus-visible,
#sidebar button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 0;
}

#sidebar input[type="number"] {
  width: 4.6rem;
}

#sidebar input[type="range"] {
  flex: 1;
  min-width: 4rem;
  margin: 0;
  padding: 0;
  background: none;
  accent-color: var(--panel-accent);
}

#sidebar input[type="color"],
#sidebar input[type="checkbox"] {
  padding: 0;
  background: none;
}

#sidebar input[type="checkbox"] {
  accent-color: var(--panel-accent);
}

#sidebar button {
  padding: 0.25rem 0.65rem;
  border: 1px solid var(--control-border);
  border-radius: 0.3rem;
  background: var(--control-bg);
  cursor: pointer;
}

#sidebar button:hover {
  border-color: var(--panel-accent);
}

.row {
  display: grid;
  grid-template-columns: 11rem 1fr;
  gap: 0.5rem;
  align-items: center;
  padding: 0.2rem 0;
}

.row.inactive {
  opacity: 0.45;
}

.row-label {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  min-width: 0;
  font-size: 0.85rem;
}

.row-label > span {
  min-width: 0;
  line-height: 1.2;
}

/* The documentation icon comes from the a.doc:before rule in common.css. */
.doc {
  flex: none;
  text-decoration: none;
  opacity: 0.6;
  visibility: hidden;
}

.row:hover .doc,
.doc:focus-visible {
  visibility: visible;
}

.doc:hover {
  opacity: 1;
}

.control {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  min-width: 0;
}

.control > * {
  min-width: 0;
}

.control output {
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.hint {
  flex-basis: 100%;
  font-size: 0.75rem;
  line-height: 1.3;
  color: var(--panel-muted);
}

.number,
.color,
.enum {
  display: flex;
  flex: 1;
  gap: 0.4rem;
  align-items: center;
}

.enum select,
.row-string input {
  flex: 1;
  width: 100%;
}

/* Color: a swatch opening the native picker, an opacity slider and the CSS value. */
.swatch {
  position: relative;
  flex: none;
  width: 1.7rem;
  height: 1.7rem;
  border: 1px solid var(--control-border);
  border-radius: 0.3rem;
  background:
    linear-gradient(var(--swatch, transparent), var(--swatch, transparent)),
    repeating-conic-gradient(#c8c8c8 0 25%, #fff 0 50%) 0 0 / 10px 10px;
  overflow: hidden;
}

#sidebar .swatch input[type="color"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

#sidebar .color .alpha {
  flex: none;
  width: 4rem;
}

#sidebar .color .css {
  flex: 1;
  font-family: var(--monospace-font-family);
  font-size: 0.75rem;
}

#sidebar .css.invalid {
  border-color: var(--error);
}

.preset-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.preset-group {
  margin-bottom: 0.6rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  align-items: center;
  margin-top: 0.5rem;
  font-size: 0.85rem;
}

/* Data sets. */
.dataset-groups {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.dataset-groups ul {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.85rem;
  line-height: 1.4;
}

.dataset-groups li {
  margin: 0;
  padding: 0.1rem 0;
}

.dataset-groups a.current {
  font-weight: 600;
  color: inherit;
}

#panel .stats {
  margin: 0.5rem 0 0;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--panel-muted);
}

#panel .stats.error {
  color: var(--error);
}

/* The exported options. */
#panel .code {
  margin: 0.5rem 0 0;
  padding: 0.5rem;
  max-height: 20rem;
  overflow: auto;
  border: 1px solid var(--panel-border);
  border-radius: 0.3rem;
  background: var(--control-bg);
  font: 0.75rem / 1.4 var(--monospace-font-family);
  white-space: pre;
  user-select: text;
}

@media (max-width: 52rem) {
  #dotatlas {
    position: relative;
    top: auto;
    bottom: auto;
    left: auto;
    right: auto;
    height: 60vh;
    margin: var(--box-padding);
  }

  #sidebar {
    position: static;
    width: auto;
    margin: var(--box-padding);
  }

  .row {
    grid-template-columns: 1fr;
    gap: 0.2rem;
  }

  .dataset-groups {
    grid-template-columns: 1fr;
  }
}
