/* Object pages: the coordinated views and the card grid on the index. Colors come
   from Material's own variables, so both themes work. Renders sit on white plates in both themes:
   they are rendered on white. */

.piece-views,
.piece-cards {
  display: grid;
  gap: 0.8rem;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  margin: 1rem 0 1.5rem;
}

.piece-views figure {
  margin: 0;
}

.piece-views img,
.piece-card img {
  background: #fff;
  border: 1px solid var(--md-default-fg-color--lightest);
  border-radius: 0.2rem;
  display: block;
  width: 100%;
}

.piece-views figcaption {
  color: var(--md-default-fg-color--light);
  font-size: 0.7rem;
  line-height: 1.3;
  margin-top: 0.3rem;
  max-width: none;
}

.md-typeset a.piece-card {
  color: var(--md-default-fg-color);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.md-typeset a.piece-card:hover .piece-title,
.md-typeset a.piece-card:focus-visible .piece-title {
  color: var(--md-accent-fg-color);
}

.piece-title {
  font-weight: 600;
}

.piece-meta {
  color: var(--md-default-fg-color--light);
  font-size: 0.7rem;
}

/* Interactive geometry viewer (javascripts/geometry-viewer.js). Until the script mounts, the
   static render inside shows; afterwards the canvas replaces it. */
.geometry-viewer {
  margin: 1rem 0 1.5rem;
  max-width: 36rem;
}

.geometry-viewer__stage {
  background: #fff;
  border: 1px solid var(--md-default-fg-color--lightest);
  border-radius: 0.2rem;
  overflow: hidden;
  position: relative;
}

.geometry-viewer__stage img {
  display: block;
  width: 100%;
}

/* Once the viewer mounts it hides the fallback; this beats the display rule above. */
.geometry-viewer__stage img[hidden] {
  display: none;
}

.geometry-viewer__stage canvas {
  cursor: grab;
  display: block;
  touch-action: none;
}

.geometry-viewer__stage canvas:active {
  cursor: grabbing;
}

.geometry-viewer__stage canvas:focus-visible {
  outline: 2px solid var(--md-accent-fg-color);
  outline-offset: -2px;
}

.geometry-viewer__tooltip {
  background: rgba(20, 24, 33, 0.88);
  border-radius: 0.2rem;
  color: #fff;
  font-size: 0.65rem;
  max-width: 14rem;
  padding: 0.3rem 0.5rem;
  pointer-events: none;
  position: absolute;
}

.geometry-viewer__legend {
  color: var(--md-default-fg-color--light);
  font-size: 0.7rem;
  margin: 0.4rem 0 0;
}

.geometry-viewer__legend .dot {
  border-radius: 50%;
  display: inline-block;
  height: 0.6rem;
  margin: 0 0.15rem 0 0.4rem;
  vertical-align: middle;
  width: 0.6rem;
}

.geometry-viewer__legend .dot:first-child {
  margin-left: 0;
}

.dot--zero {
  background: #2a5ea6;
}

.dot--pole {
  background: #b4312c;
}

/* Recipe comparison (javascripts/recipe-explorer.js): two linked views, stacked on narrow
   screens. */
.recipe-explorer {
  margin: 1rem 0 1.5rem;
  /* The preset buttons scroll here; keep the menus clear of the sticky header. */
  scroll-margin-top: 4rem;
}

.recipe-explorer__fallback[hidden] {
  display: none;
}

.recipe-explorer__toolbar {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  font-size: 0.75rem;
  gap: 0.4rem 1.2rem;
  margin-bottom: 0.6rem;
}

.recipe-explorer__toolbar .md-button {
  font-size: 0.7rem;
  margin-left: auto;
  padding: 0.25em 0.9em;
}

.recipe-explorer__panels {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}

@media screen and (min-width: 45em) {
  .recipe-explorer__panels {
    grid-template-columns: 1fr 1fr;
  }
}

.recipe-explorer__panel {
  min-width: 0;
}

.recipe-explorer__controls {
  display: flex;
  flex-wrap: wrap;
  font-size: 0.75rem;
  gap: 0.4rem 0.8rem;
  margin-bottom: 0.4rem;
}

.recipe-explorer__controls label {
  align-items: center;
  display: flex;
  gap: 0.3rem;
}

.recipe-explorer__controls select {
  background: var(--md-default-bg-color);
  border: 1px solid var(--md-default-fg-color--lighter);
  border-radius: 0.2rem;
  color: var(--md-default-fg-color);
  font: inherit;
  padding: 0.15rem 0.3rem;
}

.recipe-explorer__summary {
  color: var(--md-default-fg-color--light);
  font-size: 0.7rem;
  margin: 0.4rem 0 0;
}

.compare-presets button {
  background: none;
  border: none;
  color: var(--md-typeset-a-color);
  cursor: pointer;
  font: inherit;
  padding: 0;
  text-align: left;
}

.compare-presets button:hover {
  text-decoration: underline;
}
