/* Shared visualizer styles */

* {
  box-sizing: border-box;
}

body {
  margin: 10px;
  color: #222;
  background: #fff;
  font-family: Arial, "Noto Sans JP", "Yu Gothic UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

main {
  width: 100%;
  max-width: none;
  margin: 0 auto;
}

h1 {
  margin: 0 0 4px;
  font-size: 22px;
}

h2 {
  margin: 8px 0 5px;
  font-size: 17px;
}

h3 {
  margin: 0 0 5px;
  font-size: 15px;
}

p {
  margin: 4px 0;
}

hr {
  margin: 9px 0;
  border: 0;
  border-top: 1px solid #aaa;
}

.io-block {
  min-width: 0;
}

.io-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(320px, 2fr);
  gap: 8px;
}

.io-header {
  display: flex;
  align-items: center;
  min-height: 25px;
  gap: 4px;
}

.io-block label {
  font-weight: bold;
}

.io-block input[type="file"] {
  min-width: 0;
  margin-left: auto;
  font-size: 12px;
}

textarea {
  display: block;
  width: 100%;
  margin-top: 2px;
  padding: 4px;
  resize: vertical;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.4;
}

button {
  margin-right: 4px;
}

.actions {
  margin-top: 5px;
}

.result-line {
  margin-bottom: 4px;
}

.status {
  font-weight: bold;
}

.status-idle,
.message-idle {
  color: #555;
}

.status-visible,
.message-visible {
  color: #087830;
}

.status-illegal,
.message-illegal {
  color: #c00000;
}

.message {
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.result-table {
  width: 100%;
  margin-top: 6px;
  border-collapse: collapse;
}

.result-table th,
.result-table td {
  padding: 2px 8px 2px 0;
  text-align: left;
}

.result-table th {
  font-weight: normal;
}

.result-table td {
  font-family: Consolas, "Courier New", monospace;
}

.pattern-value {
  max-width: 160px;
  overflow-wrap: anywhere;
}

.availability-scroll {
  max-height: 310px;
  margin-top: 7px;
  overflow: auto;
  border: 1px solid #aaa;
}

.availability-table {
  width: 100%;
  border-collapse: collapse;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
}

.availability-table th,
.availability-table td {
  padding: 2px 6px;
  text-align: center;
  border-bottom: 1px solid #ddd;
}

.availability-table th {
  position: sticky;
  top: 0;
  background: #f5f5f5;
}

.availability-path {
  cursor: default;
}

.availability-path:hover,
.availability-path.is-active {
  background: #dcefff;
}

.availability-mismatch {
  color: #c00000;
  font-weight: bold;
}

.calculation-tables h4 {
  margin: 7px 0 2px;
  font-size: 13px;
}

.calculation-scroll {
  max-height: 100px;
  overflow: auto;
  border: 1px solid #aaa;
}

.calculation-table {
  width: 100%;
  border-collapse: collapse;
  font-family: Consolas, "Courier New", monospace;
  font-size: 11px;
}

.calculation-table th,
.calculation-table td {
  padding: 2px 3px;
  text-align: right;
  border-bottom: 1px solid #ddd;
}

.calculation-table th {
  position: sticky;
  top: 0;
  background: #f5f5f5;
}

.calculation-table tr {
  cursor: default;
}

.calculation-table tbody tr:hover,
.calculation-table tbody tr.is-active {
  background: #dcefff;
}

.calculation-mismatch {
  color: #c00000;
  font-weight: bold;
}

.legend {
  display: flex;
  margin-top: 10px;
  flex-direction: column;
  gap: 3px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-swatch {
  display: inline-block;
  width: 13px;
  height: 13px;
  border: 1px solid #555;
}

.record-swatch {
  background: #ffe2a8;
}

.value-swatch {
  background: linear-gradient(
    90deg,
    #daecff 0 25%,
    #ffe8be 25% 50%,
    #daf2dc 50% 75%,
    #efddff 75%
  );
}

.normal-swatch {
  background: #fff;
}

.invalid-swatch {
  background: #ffd6d6;
}

.black-swatch {
  background: #414141;
}

.start-swatch {
  background: #17824f;
}

.target-swatch {
  background: #c93d3d;
}

.legend-line {
  display: inline-block;
  width: 16px;
  height: 3px;
}

.path-line {
  background: #1683c7;
}

.visual-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 250px;
  align-items: start;
  gap: 12px;
}

.canvas-frame {
  position: relative;
  display: grid;
  overflow: auto;
  width: 100%;
  height: clamp(220px, 46vh, 520px);
  min-height: 180px;
  max-height: 75vh;
  resize: vertical;
  place-items: center;
  text-align: center;
  border: 1px solid #aaa;
}

#grid-canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  margin: 0 auto;
  border: 0;
  image-rendering: pixelated;
}

.cell-tooltip {
  position: fixed;
  z-index: 10;
  min-width: 170px;
  padding: 6px 8px;
  color: #fff;
  pointer-events: none;
  background: rgb(0 0 0 / 85%);
  border: 1px solid #fff;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.5;
  text-align: left;
  white-space: pre-line;
}

.tooltip-record {
  color: #ffd56a;
  font-weight: bold;
}

.tooltip-invalid {
  color: #ff8e8e;
  font-weight: bold;
}

.note {
  color: #555;
  font-size: 12px;
}

.seek-control {
  margin: 10px 0;
}

.seek-control label {
  display: block;
  margin-bottom: 2px;
  font-weight: bold;
}

.seek-control input[type="range"] {
  width: 100%;
}

.step-input {
  width: 5.5em;
  box-sizing: border-box;
  padding: 2px 4px;
  font: inherit;
  text-align: right;
}

.placeholder {
  color: #666;
}

.information {
  min-width: 0;
  padding-left: 12px;
  border-left: 1px solid #aaa;
}

.is-hidden {
  display: none !important;
}

@media (max-width: 700px) {
  .io-grid {
    grid-template-columns: 1fr;
  }

  .visual-layout {
    grid-template-columns: 1fr;
  }

  .information {
    padding-top: 8px;
    padding-left: 0;
    border-top: 1px solid #aaa;
    border-left: 0;
  }

  .canvas-frame {
    height: 48vh;
    max-height: 70vh;
  }
}
