:root {
  color-scheme: light dark;
}

/* ///////////////////////////////////////////////////////////// */

/* light mode default */

html {
  font-family: roboto, sans-serif;
  font-size: 14px;
  }

body {
  margin-top: 0;
  }

a {
  color: peru;
  text-decoration: none;
  }
a:visited {
  color: darkgoldenrod;
  }
a:hover {
  color: orange;
  border-bottom: 1px dotted orange;
  margin-bottom: -1px;
  }

a.unwritten {
  color: saddlebrown;
  }
a.unwritten::after {
  content: " ✐";
  color: red;
  }
#pages-todo a.unwritten::after {
  content: "";
  }



h1,
h2,
h3 {
  margin: 0;
  margin-bottom: 0.8em;
  }
h2 {
  padding: 0;
  margin-top: 15px;
  font-size: 1.2rem;
  color: saddlebrown;
  }
h3 {
  font-size: 1em;
  display: inline-block;
  }

h1 + p,
h2 + p,
h3 + p {
  margin-top: 0;
  }

p {
  margin-bottom: 0.8em;
  }
p:last-child {
  margin-bottom: 0;
  }
p:first-child {
  margin-top: 0;
  }
blockquote {
  margin: 0 10px 0 0;
  border-left: 5px double #a52a2a;
  padding: 0 5px;
  font-size: 1em;
  color: brown;
  }

.get-started-tip {
  color: #ccc;
  margin-bottom: 0.5em;
  }

.node,
.column.editor .column-head {
  padding: 0.3em 10px; /* space between has more air for larger type */
  border: 1px solid white;
  border-left: 3px solid;
  background-color: white;
  }
.column.editor .column-head {
  border-left-color: peru;
  background-color: #f9f7ed;
}
.node.primary .node-html-header {
  display: none;
  }
.column.editor .column-head h1 {
  margin-bottom: 0;
  }


.node.primary {
  opacity: 1;
  background-color: #f9f7ed;
  border-left-color: peru;
  }
.node.editing {
  border-left-color: red;
  }
.node.mentions {
  border-left-color: green;
  }
.node.backlink {
  border-left-color: blue;
  }
.node.mentionby {
  border-left-color: green;
  }
.node.taggedas {
  border-left-color: crimson;
  }
.node.classedas {
  border-left-color: orange;
  }
.node.undefined {
  border-left-color: grey;
  color: #666;
  }
.node:hover {
  border-top: 1px dashed #999 !important;
  border-bottom: 1px dashed #999 !important;
  border-right: 1px dashed #999 !important;
  }

.node-html-title {
  padding: 3px 0;
  display: inline-block;
  }

.node-html-content {
  padding: 3px 0;
  }

.node.undefined .node-html-content {
  font-size: 0.8rem;
  }

.node-edit-bar {
  position: sticky;
  top: 40px;
  background-color: black;
  }

.node-editor {
  display: none;
  background-color: #eee;
  margin: -10px;
  padding: 10px;
  }
.node.editing .node-editor {
  display: block;
  }
.node.editing .node-html {
  display: none;
  }

.nodes section {
  padding-top: 1em;
  }

.nodes section h2 {
  margin-bottom: 0;
  padding-left: 5px; /* line up just inside of node borders */
  border-bottom: 1px solid peru;
  }

button {
  color: black;
  background-color: whitesmoke;
  border: 1px silver solid;
  border-radius: 6px;
  padding: 2px 5px;
  font-size: 9px;
  }
.primary button.btn-link {
  display: none;
  }
.node button.btn-link {
  background-color: greenyellow;
  }
.node.linked button.btn-link {
  background-color: pink;
  }
.node:not(.linked) button.btn-link:before {
  content: 'Make ';
  }
.node.linked button.btn-link:before {
  content: 'Break ';
  }

.node.new .btn-delete { display: none; }

input.node-title,
textarea.node-md {
  border: 1px solid #ccc;
  padding: 5px;
  }
textarea.node-md {
  resize: vertical;
  width: 100%;
  box-sizing: border-box;
  height: 5em;
  min-height: 2em;
  max-height: 75vh;
  }
input:required:invalid {
  background-color: yellow;
  border-color: orange;
  }
input.node-title {
  width: 220px;
  font-size: 1.3em;
  font-weight: bold;
  margin-bottom: 2px;
  }

.node-html-buttons {
  float: right;
  display: none; /* TODO: make buttons, tweak positioning */
  }

.node-html h1,
.node-html h3 {
  margin: 0;
  margin-bottom: 0.3rem;
  }

.node-html ol,
.node-html ul {
  margin-top: 0;
  margin-bottom: 0.8em;
  padding-left: 1.8em;
  font-size: 90%;
  }
.node-html ol:last-child,
.node-html ul:last-child {
  margin-bottom: 0;
  }
.node-html li ul:last-child,
.node-html li ol:last-child {
  margin-bottom: 1em;
  }
.node-html li {
  padding: 0;
  margin: 0.2em 0;
  }
.node-html li p {
  margin-bottom: 0;
  }


.node-html table {
  border-collapse: collapse;
  margin-bottom: 1rem;
  }
.node-html table th { text-align: left; }
.node-html table th,
.node-html table td {
  vertical-align: text-bottom;
  font-size: 0.8em;
  padding: 1px 0.5em;
  margin: 0;
  }
.node-html tr:last-child {
   border-bottom: 1px dotted silver;
  }
.node-html tr:nth-child(2n) {
  background-color: rgba(192, 192, 192, 0.2);
  }

.node-html img {
  max-width: 100%;
  }

/* tag shaped links */
.primary .tag,
.primary .class,
.nodes-direct .node.taggedas .node-html-title a,
.nodes-direct .node.classedas .node-html-title a {
  display: inline-block;
  font-size: 0.875em;
  color: #000;
  background: #ccc;
  height: 25px;
  line-height: 25px;
  border-radius: 5px 0 0 5px;
  margin-right: 1rem;
  padding: 0 0.666rem;
  text-align: center;
  position: relative;  /* need this for the z-index to work */
  z-index: 0;          /* need this so the :after can be layered under */
  cursor: pointer;
  }

.primary .class,
.nodes-direct .node.classedas .node-html-title a {
  background: #e6ddb3;
  }

.tag.unwritten {
  color: #333333;
  background-color: #dddddd;
  }

.primary .tag:after,
.primary .class:after,
.nodes-direct .node.taggedas .node-html-title a:after,
.nodes-direct .node.classedas .node-html-title a:after {
  background: inherit;
  border-radius: 5px;
  transform-origin: top left;
  transform: rotate(45deg);
  content: "";
  display: block;
  height: 21px;
  width: 20px;
  right: -19px;
  top: -2px;
  position: absolute;
  z-index: -1;
  }

.nodes-direct .node.taggedas .node-html-title a,
.nodes-direct .node.classedas .node-html-title a {
  margin-left: -8px;
  }

.primary .tag:hover,
.primary .class:hover,
.nodes-direct .node.taggedas .node-html-title a:hover,
.nodes-direct .node.classedas .node-html-title a:hover,
.nodes-direct .node.taggedas .node-html-title a:hover h3,
.nodes-direct .node.classedas .node-html-title a:hover h3 {
  border-bottom: none;  /* clear default a:hover behaviour set elsewhere */
  margin-bottom: 0;     /* clear default a:hover behaviour set elsewhere */
  background-color: crimson;
  color: white;
  }

/* don't display .tag or .class inside related content */
.node:not(.primary) .node-html-content .tag,
.node:not(.primary) .node-html-content .class {
  display: none;
  }


.heading-direct {
  font-style: italic;
  font-weight: normal;
  }
.heading-reverse {
  font-style: italic;
  font-weight: normal;
  }

#site-btns {
  margin-top: 5px;
  }

#data-dump {
  font-size: 11px;
  }
#data-dump .hide {
  display: none;
  }
#data-dump pre {
  border: 1px dashed #ccc;
  background: #eee;
  padding: 0;
  }
#data-dump pre:first-child {
  margin: 0;
  }


#pages {
  font-size: 0.8em;
  }

#pages-meta {
  display: flex;
  align-items: center;
  }
#pages-counts {
  flex-grow: 1;
  }

#pages-finder-input {
  width: 150px;
  }


#pages-list {
  column-count: 3;
  column-gap: 5px;
  }
#pages-list ul {
  margin-top: 0;
  margin-bottom: 0;
  padding-left: 0;
  list-style-type: none;
  }
#pages-list ul li {
  padding-left: 0.5em;
  text-indent: -0.5em;
  }


.column .column-head h2 {
  margin: 0;
  }

.column-content {
  padding: 0 5px;
  }
.editor .column-content {
  padding: 0;
  }
.column-content :first-child {
  margin-top: 0;
  }
.column-content :last-child {
  margin-bottom: 0;
  }

:focus-visible {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}

:focus:not(:focus-visible) { /* hide focus outline if clicked, not if tabbed */
  outline: none;
  }


#changes table.changes { width: 100%; margin-top: 1em;}
#changes table.changes th { text-align: left; }
#changes div.preamble dt { font-weight: bold; }
#changes table time { white-space: nowrap; }
#changes table.changes td { vertical-align: top; }


/* multi-columns tableau /////////////////////////////////////// */

body {
  display: flex;
  flex-direction: column;
  max-height: 100vh;
  padding: 0 5px;
  margin: 0;
  }

body > header {
  height: 30px;
  }

header,
footer {
  z-index: 1;
  padding: 10px 10px;
  margin: 0 -5px;
  background-color: black;
  color: white;
  font-family: sans-serif;
  }

header a,
footer a {
  color: white;
  }

header .site-id {
  font-weight: bold;
  color: #f70; /* fiery orange */
  }

header .document-id {
  font-style: italic;
  }

footer {
  font-size: 0.7em;
  }

main {
  height: 100vh;
  width: 100%;
  margin: 5px 0;
  display: flex;
  column-gap: 3px;
  overflow-x: auto;
  }

.column {
  background-color: #eeeeee; /* opaque, inherited by h2 */
  border: 1px solid grey;
  width: 400px;
  min-width: 400px;
  overflow: auto;
  }
.column .column-head {
  padding: 5px 5px;
  margin: 0;
  top: 0; /* needed for sticky */
  position: sticky;
  position: -webkit-sticky; /* support older iPad */
  z-index: 1;
  background: inherit; /* to hide scrolling content */
  }

/* ///////////////////////////////////////////////////////////// */

@media (prefers-color-scheme: dark) {

html {
  color: #E3DAC9;
  background-color: #181818;
  }

body {
  background-color: #181818;
  }

a.unwritten {
  color: #c08060;
  }

h2 {
  color: #E3DAC9;
  }

hr {
  border: none;
  border-top: 1px solid darkgoldenrod;
  }

blockquote {
  color: #c08080;
  }

.get-started-tip {
  color: #999;
  }

.node,
.column.editor .column-head {
  border-color: #444;
  background-color: #443324;
  }

.column.editor .column-head {
  background-color: #6d4b2c;
  }

.node.primary {
  background-color: #443324;
  }

.nodes-direct .node,
.nodes-reverse .node {
  background-color: #29271f;
  }

.node.undefined {
  color: #999;
  }

.node:hover {
  border-top-color: #666 !important;
  border-bottom-color: #666 !important;
  border-right-color: #666 !important;
  }

.node-editor {
  background-color: #303030;
  }

button {
  color: #ddd;
  background-color: #333;
  border-color: #666;
  }

.node button.btn-link {
  background-color: #6a8f00;
  }

.node.linked button.btn-link {
  background-color: #8f4f5f;
  }

input.node-title,
textarea.node-md {
  border-color: #555;
  background-color: #222;
  color: #ddd;
  }

input:required:invalid {
  background-color: #665500;
  }

.node-html tr:last-child {
  border-bottom-color: #666;
  }

.node-html tr:nth-child(2n) {
  background-color: rgba(192, 192, 192, 0.08);
  }

/* tag shaped links */

.primary .tag,
.primary .class,
.nodes-direct .node.taggedas .node-html-title a,
.nodes-direct .node.classedas .node-html-title a {
  color: #ddd;
  background: #444;
  }

.primary .class,
.nodes-direct .node.classedas .node-html-title a {
  background: #655d3c;
  }

.tag.unwritten {
  color: #ccc;
  background-color: #444;
  }

#data-dump pre {
  border-color: #555;
  background: #242424;
  }

.column {
  background-color: #202020;
  border-color: #555;
  }

}
