/* The Supertiles view — a supertile taken apart into the pieces it is made of.

   Layout discipline, same rule as .map-viewport / .explorer-viewport: the
   viewport has a DETERMINISTIC height and the drawing lives inside it, so the
   viewport never sizes itself from its own contents. */

.supertiles-page {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.supertiles-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}
.supertiles-title h1 {
  margin: 0 0 4px;
  font-size: 24px;
}
.supertiles-title p {
  margin: 0;
  max-width: 620px;
}

.supertiles-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
}
.supertiles-control {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}
.supertiles-control strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.supertiles-control select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 8px;
  font: inherit;
  min-width: 90px;
}
.supertiles-slider input[type='range'] {
  width: 132px;
  accent-color: var(--accent);
}
.supertiles-check {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  padding-bottom: 6px;
}
.supertiles-controls button {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 12px;
  font: inherit;
  cursor: pointer;
}
.supertiles-controls button:hover {
  border-color: var(--accent);
}

/* The substitution rule, as a row of chips in the pieces' own colours. */
.supertiles-rule {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  font-size: 13px;
}
.supertiles-chip {
  display: inline-block;
  padding: 1px 7px;
  border: 1px solid rgba(16, 19, 26, 0.35);
  border-radius: 999px;
  color: #10131a;
  font-size: 12px;
}
.supertiles-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.supertiles-viewport {
  position: relative;
  height: calc(100vh - 320px);
  min-height: 380px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
}
.supertiles-viewport .panzoom {
  width: 100%;
  height: 100%;
}
/* While a new layout is being built the old one stays on screen; dimming it
   says "this is the previous frame" without the view ever going blank. */
.supertiles-viewport.is-stale .supertile-view {
  opacity: 0.55;
  transition: opacity 120ms linear;
}
.supertile-view {
  display: block;
  width: 100%;
  height: 100%;
}
.supertile-label {
  pointer-events: none;
  font-family: var(--mono, ui-monospace, monospace);
}

.supertiles-hud {
  position: absolute;
  top: 8px;
  left: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 9px;
  border-radius: var(--radius);
  background: rgba(16, 19, 26, 0.78);
  color: #e8ecf5;
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 12px;
  pointer-events: none;
}

.supertiles-note {
  margin: 0;
  font-size: 13px;
}

@media (max-width: 780px) {
  .supertiles-viewport {
    height: calc(100vh - 420px);
  }
  .supertiles-slider input[type='range'] {
    width: 104px;
  }
}

/* Rule + analysis panel below the viewport. The Explorer keeps these in a
   sidebar; here the picture is the wide thing, so they run underneath it in
   columns that reflow rather than squeezing the viewport. */
.supertiles-rulepanel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  align-items: start;
}
/* The ten matching editors want width, not a column: given one they stack into
   a tower taller than the picture they belong to. */
.supertiles-rulepanel .explorer-matchings,
.supertiles-rulepanel .explorer-advanced {
  grid-column: 1 / -1;
}
.supertiles-rulepanel fieldset,
.supertiles-rulepanel details {
  margin: 0;
}
/* The matching grid is sized for a sidebar; here it runs across the page. */
.supertiles-rulepanel .matching-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.supertile-strand {
  pointer-events: none;
}
