/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Variables
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

:root {
  --fg-1: #000000;
  --fg-2: #999999;
  --bg-1: #ffffff;
  --bg-2: #dddddd;

  --primary: #deefff;
  --tertiary: #bbccde;
  --highlight: #f6eb61;
  --stripe: rgba(36, 36, 35, 0.05);

  --link: #0000ee;
  --link-active: #ff0000;
  --link-visited: #551a8b;

  --conflict-red: #facbd9;
  --solution-green: #55ff2b;

  --default-font: Outfit, Helvetica, Arial, sans-serif;
  --monospace-font: DMMono, "Courier New", Courier, monospace;

  --restart-node-size: 32px;
  --restart-canvas-padding: 32px;
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Fonts
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

@font-face {
  font-family: Outfit;
  src: url("../fonts/Outfit-Regular.ttf");
  font-display: swap;
}

@font-face {
  font-family: Outfit;
  src: url("../fonts/Outfit-Bold.ttf");
  font-display: swap;
  font-weight: bold;
}

@font-face {
  font-family: DMMono;
  src: url("../fonts/DMMono-Regular.ttf");
  font-display: swap;
}

@font-face {
  font-family: DMMono;
  src: url("../fonts/DMMono-Italic.ttf");
  font-display: swap;
  font-style: italic;
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * General
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

* {
  padding: 0px;
  margin: 0px;
  box-sizing: border-box;
}

html {
  font: 12pt / 1.5 var(--default-font);
}

body {
  color: var(--fg-1);
  background-color: var(--bg-2);

  padding: 32px 0px 0px 0px;

  text-align: center;
}

h1,
h2,
h3,
h4,
h5,
h6,
th {
  font-weight: normal;
}

h1,
h2 {
  margin-top: 16px;
}

a {
  color: var(--link);
  text-decoration: none;
}

a:hover {
  text-decoration: underline 1px solid currentColor;
}

a:active {
  color: var(--link-active);
}

a:visited {
  color: var(--link-visited);
}

button,
input[type="file"]::file-selector-button,
input[type="submit"] {
  padding: 2px 4px;
  margin: 4px;

  color: var(--fg-1);
  background-color: var(--bg-1);

  font-family: var(--default-font);
  font-size: 1rem;

  border: 1px solid var(--fg-2);
  border-radius: 8px;
}

button:hover,
input[type="file"]::file-selector-button:hover,
input[type="submit"]:hover {
  background-color: var(--bg-2);
}

button:active,
input[type="file"]::file-selector-button:active,
input[type="submit"]:active {
  background-color: var(--primary);
  border-color: var(--bg-2);
}

select {
  background: var(--bg-1);

  padding: 2px 4px;
}

select:hover {
  background: var(--bg-2);
}

select:active {
  background: var(--primary);
}

code > pre {
  text-align: left;
  padding: 8px;
}

summary {
  cursor: pointer;
  font-size: 1.2rem;
  margin-block: 4px;
  padding: 4px;
  border-radius: 8px;
}

summary:hover {
  background: var(--bg-2);
}

img {
  max-width: 100%;
  max-height: 100%;
}

div.plain-text {
  text-align: left;
  padding: 16px;
}

div.plain-text footer {
  padding-top: 16px;
  text-align: center;
}

div.plain-text footer img {
  max-height: 64px;
  margin-inline: 16px;
}

p,
dd {
  max-width: 55ch;
  hyphens: auto;
  text-align: justify;
}

p {
  margin-block: 8px;
}

dt {
  font-weight: bold;
}

dt {
  margin-top: 8px;
}

dd {
  margin-left: 1ch;
}

hr {
  margin: 16px auto;
  color: var(--fg-1);
  background: var(--fg-1);
}

*.hidden {
  display: none;
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Control panel
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

nav#control-panel {
  position: absolute;
  z-index: 999;
  top: 0;
  left: 0;
  right: 0;
  height: 40px;
  background-color: var(--tertiary);
  border-bottom: 1px solid var(--fg-1);
  display: grid;
  grid-template:
    "load visu plum" 1fr
    / min-content 1fr min-content;
  gap: 4px;
  padding: 4px;
}

nav#control-panel > span {
  white-space: nowrap;
  overflow-x: auto;
}

nav#control-panel > span > * {
  display: inline;
}

span#load-instance-buttons {
  grid-area: load;
  text-align: left;
}

span#visualization-buttons {
  grid-area: visu;
  text-align: center;
  border-inline: 1px solid var(--fg-2);
}

span#plumbing-buttons {
  grid-area: plum;
  text-align: right;
}

nav#control-panel button {
  margin: 4px;
  padding: 2px 4px;
  width: min-content;
  white-space: nowrap;
}

select#load-instance-select {
  margin-top: 4px;
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Trail table
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

table#trail-table {
  width: 100%;
  border-collapse: collapse;
}

table#trail-table th {
  border-bottom: 1px solid var(--fg-2);
  position: sticky;
  top: 0px;
  background-color: var(--bg-1);
}

table#trail-table th + th {
  border-left: 1px solid var(--fg-2);
}

table#trail-table td {
  font-family: var(--monospace-font);
  font-size: 10pt;
  white-space: pre;
  border-bottom: 1px solid var(--fg-2);
}

table#trail-table td.level {
  vertical-align: top;
  border-right: 1px solid var(--fg-1);
}

table#trail-table td.assignments {
  cursor: pointer;
}

table#trail-table td.focus {
  background-color: var(--highlight);
}

table#trail-table tbody.largest ~ tbody {
  display: none;
}

table#trail-table div.assignment {
  margin: 2px auto;
  padding: 2px 4px;
  width: fit-content;
}

table#trail-table div.assignment:first-child {
  background-color: var(--bg-2);
  border-radius: 8px;
}

table#trail-table div.assignment.conflict {
  background-color: var(--conflict-red);
  border-radius: 8px;
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Restart Trees
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

span.control-bar {
  position: absolute;
  left: 8px;
  top: 40px;
}

span.control-bar button {
  width: 32px;
  height: 32px;
  padding: 8px;
  margin: 2px;
}

span.control-bar:not(.show-stop-button) button.stop-button {
  display: none;
}

span.control-bar.show-stop-button button.play-button {
  display: none;
}

moving-window.restart movwin-body {
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0),
    rgba(0, 0, 0, 0) 50%,
    var(--stripe) 50%,
    var(--stripe)
  );

  background-size: 100% calc(10 * var(--restart-node-size));
  background-position-y: calc(var(--restart-canvas-padding) / 2);
}

moving-window.restart svg text {
  cursor: pointer;
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Clause Tables
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

table.clauses {
  width: 100%;
  border-collapse: collapse;
}

table.clauses td {
  font-family: var(--monospace-font);
  font-size: 10pt;
  white-space: pre;
  padding: 1px 8px;
}

table.clauses td:first-child {
  text-align: left;
}

table.clauses td:last-child {
  text-align: right;
}

table.clauses tr:nth-child(even) {
  background-color: var(--stripe);
}

table.clauses tr.future-clause {
  color: var(--fg-2);
}

table.clauses tr.conflicting {
  background: var(--conflict-red);
}

table.clauses.focus tr.learned-clause:has(+ tr.future-clause),
table.clauses.focus tr.learned-clause:last-child {
  background-color: var(--highlight);
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * SVG / D3
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

circle.focus {
  fill: var(--highlight);
}

circle.hidden-children {
  filter: drop-shadow(0px 5px 1px rgb(0 0 0 / 1));
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Moving Windows
 * Some styling unfortunately has to be done in the JS declaration for the
 * element
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

moving-window {
  --button-height: 25px;
  --header-padding-y: 4px;

  position: absolute;

  display: none;
  overflow: hidden;
  resize: both;

  background-color: var(--bg-1);
  border: 1px solid var(--fg-1);

  min-width: 128px;
  width: 128px;
  /* max-width:95vw; */

  min-height: calc(var(--button-height) + 2 * var(--header-padding-y));
  height: fit-content;
  /* max-height:95vh; */

  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

moving-window[open],
moving-window[permanent] {
  display: block;
}

movwin-header {
  display: block;
  overflow: hidden;

  border-bottom: 1px solid var(--fg-1);
  background-color: var(--primary);

  text-align: left;
  padding: var(--header-padding-y);
}

movwin-header:hover {
  cursor: pointer;
}

movwin-header > h3 {
  overflow: hidden;
  white-space: nowrap;
  font-weight: normal;
}

movwin-header > button {
  float: right;

  margin: 0px;

  border: 1px solid var(--fg-1);
  border-radius: 0px;

  width: 32px;
  height: var(--button-height);
}

movwin-header > button + button {
  border-right: none;
}

movwin-header > button[name="close"]:hover {
  background-color: var(--conflict-red);
}

moving-window[permanent] > movwin-header > button[name="close"] {
  background-color: var(--bg-2);
}

movwin-header > button[name="minimize"]:hover {
  background-color: var(--highlight);
}

movwin-body {
  display: block;
  overflow: auto;

  height: calc(100% - var(--button-height) - 2 * var(--header-padding-y));
  min-height: 64px;
}

moving-window[minimized] {
  resize: horizontal;
}

moving-window[minimized] > movwin-body {
  display: none;
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Initial window positions.
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

moving-window#trail {
  width: 128px;
  top: 48px;
  left: 8px;
  height: calc(100vh - 2 * 8px - 40px);
}

moving-window.restart {
  --restart-width: calc(100vw - 128px - 256px - 4 * 8px);

  left: calc(128px + 2 * 8px);
  top: 48px;

  width: var(--restart-width);
  height: calc(100vh - 2 * 8px - 40px);
}

moving-window#initial {
  right: 8px;
  top: 48px;
  width: 256px;
  height: calc(50vh - 1.5 * 8px - 20px);
}

moving-window#learned {
  right: 8px;
  bottom: 8px;
  width: 256px;
  height: calc(50vh - 1.5 * 8px - 20px);
}

moving-window#cnf {
  top: 64px;
  left: 32px;
  width: 256px;
  height: 512px;
}

moving-window#log {
  top: 128px;
  left: 64px;
  width: 256px;
  height: 512px;
}

moving-window#about {
  top: 64px;
  left: calc(50vw - 256px);
  width: 512px;
}

moving-window#upload {
  --upload-height: 256px;
  --upload-width: 256px;
  height: var(--upload-height);
  width: var(--upload-width);
  top: calc(50% - (var(--upload-height) / 2));
  left: calc(50% - (var(--upload-width) / 2));
}

moving-window#file_preview_window {
  --file_preview-height: 256px;
  --file_preview-width: 256px;
  height: var(--file_preview-height);
  width: var(--file_preview-width);
  top: calc(50% - (var(--file_preview-height) / 2));
  left: calc(75% - (var(--file_preview-width) / 2));
}

moving-window#implication-graph {
  left: 64px;
  width: 512px;
}

moving-window#stats-graph {
  left: 16px;
  top: 64px;
  width: max-content;
  height: max-content;
}

moving-window#stats-graph div {
  margin: 8px;
}

moving-window #stats-graph svg {
  width: auto;
  height: auto;
  display: block;
}
