/* Page layout */

html {
  background: var(--bg);
  color: var(--fg);
  overflow-wrap: break-word;
  scroll-behavior: smooth;
}

* {
  margin: 0px;
}

::selection {
  background: #ace0e399;
}

#content {
  padding-left: 20px;
  padding-right: 20px;
  margin-top: 20px;
  margin-left: max(0px, calc(50% - 350px));
  margin-right: max(0px, calc(50% - 350px));
}

header {
  margin-bottom: 18px;
}

/* Metadata */

.header {
  margin-top: 10px;
}

.header .meta {
  margin-top: 10px;
}

.meta {
  --color: var(--meta-fg);
  --bg-color: var(--meta-bg);
  font-weight: 400;
  font-size: 12px;
  line-height: 1.1rem;
  display: flex;
  flex-direction: column;
}

.meta.row {
  flex-direction: row;
  gap: 6px;
}

.meta .meta-item {
  color: var(--color);
  background-color: var(--bg-color);
  border-radius: 5px;
  padding: 1px 4px 1px;
}

.meta .tag {
  --bg-color: var(--meta-tag-bg);
}

.meta .parent {
  --bg-color: var(--meta-parent-bg);
}

.meta .property {
  --bg-color: var(--meta-property-bg);
}

.meta .timestamp {
  font-size: 1em;
  background: none;
}

.meta .time {
  --bg-color: var(--meta-time-bg);
}

#header-figure {
  background: white;
  display: flex;
  align-items: center;
  border: 0.8px solid #aaa;
  min-height: 100px;
  max-height: 150px;
  text-align: center;
  overflow-y: hidden;
}

#header-figure > div {
  margin-left: auto;
  margin-right: auto;
}

/* Foldable */

.foldable:not([open]) {
  box-shadow: -2px 0 0 #5321;
  padding-left: 10px;
}

.foldable:hover:not([open]) {
  box-shadow: -2px 0 0 #5323;
}

/* Headings */

h1 {
  font-weight: 400;
  font-size: 33px;
  letter-spacing: -0.20001px;
  line-height: 140%;
}

#content .subtitle {
  margin-top: 0px;
}

h2 {
  font-size: 26px;
  margin-top: 20px;
}

h3 {
  font-size: 22px;
  margin-top: 20px;
}

h4,
h5,
h6 {
  font-size: 20px;
  margin-top: 20px;
}

h1 a, h2 a, h3 a, h4 a, h5 a {
  text-decoration: 2px underline dotted;
}

h1 a:hover, h2 a:hover, h3 a:hover, h4 a:hover, h5 a:hover {
  background: #f5f5dc;
  border-radius: 5px;
}

/* Headlines */

section > details > summary {
  list-style: none;
  cursor: pointer;
}

section > details > summary::-webkit-details-marker {
  display: none;
}

.headline {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.headline .meta {
  text-align: right;
}

.headline .todokw.todo {
  --color: #ce3800;
  --bg-color: #ffcfc9;
}

.headline .todokw.done {
  --color: #008000;
  --bg-color: #bcebbc;
}

.headline .priority.A {
  --color: #e84e00;
  --bg-color: #e84e0033;
}

.headline .priority.B {
  --color: #df9300;
  --bg-color: #eaac3333;
}

.headline .priority.C {
  --color: #90a652;
  --bg-color: #90a65233;
}

/* Paragraphs */

#content p {
  margin-top: 10px;
  line-height: 1.4em;
}

/* Figures */

#content img {
  display: block;
  max-width: 60%;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 20px;
  mix-blend-mode: multiply;
}

#content figure {
  overflow: auto hidden;
}

#content figure img {
  display: block;
  max-width: 60%;
}

#content figure object {
  margin-left: auto;
  margin-right: auto;
  display: block;
  overflow-x: auto;
  mix-blend-mode: multiply;
}

/* Lists */
#content :not(li) > ul, #content :not(li) > ol {
  margin-top: 10px;
}

#content ul, #content ol {
  padding-left: 0px;
  margin-left: 20px;
  line-height: 1.3em;
}


#content li {
  margin-bottom: 0em;
}

/* Code */

code {
  background: #3331;
  padding: 1px 4px;
  margin: 0px 1px;
  border-radius: 0.2em;
  font-size: 0.7em;
}

pre.code {
  background: #33333308;
  display: grid;
  overflow-x: auto;
  margin: 10px 0px;
  border: 1px solid #ddd;
  padding: 10px;
  border-radius: 10px;
}

pre code {
  background: none;
}

/* Backlinks */

div.backlink {
  font-size: 90%;
  color: #444;
  border-radius: 5px;
  margin: 5px 0px;
}

.backlink > .bl-title {
  font-weight: 500;
  font-size: 18px;
  text-overflow: ellipsis;
  max-width: 95%;
  overflow: hidden;
  padding: 5px 0px;
  white-space: nowrap;
}

.backlink > .bl-title > a {
  background: var(--bl-title-bg);
  padding: 0px 5px;
  text-decoration: 1px #777 underline dotted;
}

.backlink > .bl-body {
  font-size: 0.9em;
  color: #000d;
  max-height: 140px;
  overflow-y: auto;
  padding-top: 5px;
  padding-right: 6px;
  padding-bottom: 5px;
  mask-image: linear-gradient(transparent 0px, black 10px 140px, transparent 150px);
}
.backlink > .bl-body > p {
  margin: 0px !important;
}

.backlink > .bl-body > p:before {
  content: '“';
}

.backlink > .bl-body > p:after {
  content: '”';
}

/* Footnotes */

.fn-tooltip {
  display: none;
  font-style: italic;
}

.fn-container:focus-within .fn-tooltip {
  display: inline;
}

/* page grids */
.grid {
  display:grid;
  position: relative;
  grid-template-rows: masonry;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 15px;
  margin: 10px 0px;
}
.grid .cell {
  display: block;
  border: 1px solid #3333;
  border-radius: 10px;
  background: #fff3;
  overflow: hidden;
  height: fit-content;
}
.grid .excerpt {
  height: 135px;
  border-bottom: 1px solid #0002;
  overflow: hidden;
  text-align: center;
  font-size: 20px;
  display: flex;
  align-items: center;
}
.grid .excerpt img {
  width: 100%;
}
.grid .title {
  padding: 8px 10px 6px;
  font-size: 18px;
  font-weight: 400;
}
.grid a.link {
  text-decoration: none;
}
.grid .mosaic-meta {
  padding: 4px 0px 10px 10px;
}

/* Special blocks */

.note {
  margin: 10px 0px;
  border-radius: 10px;
  overflow: hidden;
  background: white;
  font-size: 0.94rem;
  border: 1px solid black;
}

.note .content {
  padding: 0px 15px 4px 15px;
}

.note .heading {
  font-size: 0.8rem;
  color: black;
  height: 20px;
  line-height: 1rem;
  border-bottom: 1px solid black;
  padding: 1px 8px;
  background: #a9cdb2;
}

.transclusion {
  margin: 10px 0px;
  font-size: 0.93rem;
}

.transclusion .source {
  font-style: italic;
  text-align: right;
  padding-right: 30px;
  font-size: 0.85rem;
}

.transclusion .source a {
  background: var(--bl-title-bg);
}

/* Foot */

.page-foot {
  font-size: 70%;
  font-family: "IBM Plex Sans", "Twemoji Mozilla", sans-serif;
  color: #a6a2a0;
  text-align: center;
  padding: 4em 1em 2em 1em;
  line-height: 1.6em;
}

.page-foot a:link {
  text-decoration: none;
}
.page-foot .icons {
  font-size: 130%;
  margin-top: 5px;
}

/* Math-related */

mjx-container {
  overflow-x: auto;
  overflow-y: hidden;
}

.inl {
  display: inline;
  vertical-align: middle;
  margin: 0 6px;
  max-height: 1.5em;
}

.theorem {
  border-radius: 7px;
  /* border: 1px solid #ccc; */
  padding: 0px 15px;
  margin: 15px 0px;
  font-style: italic;
  font-size: 0.97rem;
}

.theorem em {
  font-weight: 500;
  font-style: normal;
}

.theorem-name {
  font-style: normal;
  font-weight: 600;
  letter-spacing: -0.3px;
}

.theorem > p:first-of-type {
  display: inline;
}

.proof {
  position: relative; /* necessary for :after below! */
  border-radius: 7px;
  margin: 15px 0px;
  font-size: 0.97rem;
}

.proof::after {
  content: "■";
  position: absolute;
  right: 20px;
  bottom: -3px;
}

.proof-name {
  font-style: italic;
  font-weight: 600;
  letter-spacing: -0.3px;
}

.proof > p:first-of-type {
  display: inline;
}
