@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600;700&family=Source+Sans+Pro&family=Inconsolata:wdth,wght@75,300&display=swap');

// Base
// ******************************************************************************************

:root {
  --handrail-offset: 1.25rem;
  --side-padding: 6.5em;
  --handrail-margin-block: 1.5rem;
  --halmos-side-length: 0.5rem;
  --ellipsis-width: 1em;

  --gray-900: #2C343A;
  --gray-800: #404C54;
  --gray-700: #53646E;
  --gray-600: #677B89;
  --gray-500: #7F929F;
  --gray-400: #99A8B2;
  --gray-300: #B3BFC6;
  --gray-200: #CED5DA;
  --gray-100: #E8EBED;
  --white: #FFFFFF;

  --lgt-gray: #B3BFC6;
  --med-gray: #7F929F;
  --drk-gray: #2C343A;

  --link-color: #108969;
  --link-color-hover: #69B4A9;
  --keyword-blue: #005187;
  --hilite-color: #B1E9B1;

  --clock-color: #DD6F40;
  --star-color: #22a695;

  --body-line-height: 1.5;
  --header-line-height: 1.3;

  --h1-size: 3.052rem;
  --h2-size: 2.441rem;
  --h3-size: 1.953rem;
  --h4-size: 1.563rem;
  --h5-size: 1.250rem;
  --h6-size: 1.000rem;
  --font-size: 100%;

  --bold: 700;
  --semi: 600;
  --medium: 500;
  --regular: 400;
  --light: 300;

  --border-thick: 6px;
  --border-med: 4px;
  --border-thin: 2px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
}

p,
ol.enumerate,
ul.itemize {
  margin-block-end: 1em;
}

ul.contents {
  padding-inline-start: 0;
  list-style: none;

  ul.itemize {
    list-style: none;
    padding-inline-start: 2rem;
    margin-block-end: 0;
  }

}

p:has(+ .mathblock) {
  margin-block-end: 0;
}

div.statement p {
  margin-block-end: 0;
}

h1,
h2,
h3,
h4,
h5 {
  font-family: 'Montserrat', sans-serif;
  line-height: var(--header-line-height);
}

h1 {
  font-size: var(--h1-size);
  font-weight: var(--bold);
  margin: var(--h1-size) 0 var(--h1-size) 0;
}

h2 {
  font-size: var(--h2-size);
  font-weight: var(--semi);
  margin: var(--h2-size) 0 var(--h2-size) 0;
}

h3, p.topic-title {
  font-size: var(--h3-size);
  font-weight: var(--medium);
  margin: var(--h3-size) 0 var(--h3-size) 0;
}

h4 {
  font-size: var(--h4-size);
  font-weight: var(--medium);
  margin: var(--h4-size) 0 var(--h4-size) 0;
}

h5 {
  font-size: var(--h5-size);
  font-weight: var(--regular);
  margin: var(--h5-size) 0 var(--h5-size) 0;
}

section.level-1 {
  margin-block: calc(var(--h1-size));
}

@for $i from 2 through 5 {
  section.level-#{$i} {
    margin-block: calc(var(--h#{$i}-size) * 1.5);
  }
}

div.topic {
  margin-block: calc(var(--h3-size) * 1.5);
}

body {
  color: var(--drk-gray);
  font-family: 'Source Sans Pro', sans-serif;
  font-size: var(--font-size);
  font-weight: var(--regular);
  line-height: var(--body-line-height);
}

.hide {
  display: none !important;
}


/* Layout */
/******************************************************************************************/

.manuscriptwrapper {
  border-radius: 8px;
  margin: 0 auto;
  max-width: 960px;
  overflow: hidden;
  padding: 0 var(--side-padding) 0 var(--side-padding);
}

figure {
  margin-block: var(--h2-size);
  text-align: center;
}

figcaption {
  text-align: center;
  margin-block: var(--h4-size);
}

img, svg {
  max-width: 100%;
}

.handrail {
  border-bottom-left-radius: 5px;
  border-width: 0 0 0 var(--border-thin);
  border-color: var(--lgt-gray);
  border-style: solid;
  padding: 0 0 0 var(--handrail-offset);
  margin-block: var(--handrail-margin-block) var(--handrail-margin-block);
  position: relative;

  &__icons {
    align-items: flex-end;
    display: none;
    flex-direction: column;
    font-size: .8rem;
    left: 0;
    position: absolute;
    top: .5rem;
    transform: translateX(calc(-100% - 1.5*var(--handrail-offset)));
  }

  &__icons--stars {
    color: var(--star-color);
  }

  &__icons--clocks {
    color: var(--clock-color);
  }

  &--hug {
    margin-block: 0 0;
    padding: 0 0 0 var(--handrail-offset);
  }

  & .proof__title, .theorem__title {
    padding-block: 1rem;
  }

  &--hug > p:not(.topic-title), &--hug > .proof__title {
    padding-block: 0;
  }

  &--offset {
    transform: translateX(calc(-1 * var(--handrail-offset) - var(--border-thin)));
    width: calc(100% + var(--handrail-offset) + var(--border-thin));
  }

  & .handrail--offset {
    border-width: 0 0 0 0;
  }

  @for $i from 1 through 5 {
    & > h#{$i} {
      margin-block: calc(var(--h#{$i}-size) / 2);
      padding-block: calc(var(--h#{$i}-size) / 2);
    }
  }

}

.proof > .handrail.collapsed .halmos:last-of-type {
  bottom: 0;
}

.halmos {
  display: flex;
  justify-content: flex-end;
  position: absolute;
  right: 0;
  bottom: 1rem;

  &::after {
    content: '';
    display: block;
    position: absolute;
    right: 0;
    height: var(--halmos-side-length);
    width: var(--halmos-side-length);
    background-color: var(--keyword-blue);
  }

  &.with-ellipsis::before {
    content: '';
    display: flex;
    border-style: solid;
    border-color: var(--keyword-blue) var(--keyword-blue) var(--keyword-blue) var(--keyword-blue);
    border-width: .0625em 0 .0625em .0625em;
    position: absolute;
    right: 8px;
    width: var(--ellipsis-width);
    height: var(--halmos-side-length);
    justify-content: space-evenly;
    align-items: center;
    background:
      radial-gradient(farthest-side, var(--keyword-blue) 100%, transparent) 2px/2px 2px,
      radial-gradient(farthest-side, var(--keyword-blue) 100%, transparent) 6px/2px 2px,
      radial-gradient(farthest-side, var(--keyword-blue) 100%, transparent) 10px/2px 2px;
    background-repeat: no-repeat;
  }

}

.options {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  position: absolute;
  font-family: 'Montserrat', sans-serif;
  font-weight: var(--light);
  font-size: 0.75rem;
  padding-block: .5em;
  top: 2em;
  right: 0;
  z-index: 1;
  background: var(--gray-100);
  color: var(--drk-gray);

  & .option {
    display: block;
    padding-inline: .75em;
    width: 100%;
    text-align: end;
  }

}

.handrail__btn {
  padding-inline: .1em;

  &.handrail__btn--relative {
    position: relative;
  }

  &-container {
    position: absolute;
    left: calc(-1.15em);
    background: var(--gray-100);
    font-weight: var(--bold);
    display: none;

    & .handrail__btn:last-of-type  {
      border-width: 0 0 0 var(--border-thin);
      border-color: var(--lgt-gray);
      border-style: solid;
    }

  }

}

.handrail.handrail--hug > .handrail__btn-container {
  top: 0;
}

#abstract div.handrail > .handrail__btn-container,
#contents div.handrail > .handrail__btn-container {
  top: calc((var(--header-line-height)*var(--h3-size) - var(--body-line-height)*1rem)/2);
}

div.theorem > .handrail > .handrail__btn-container,
div.proof > .handrail > .handrail__btn-container {
  top: 1rem;
}

@for $i from 1 through 5 {
  section.level-#{$i} > .handrail > .handrail__btn-container {
    top: calc(var(--h#{$i}-size)/2 + (var(--header-line-height)*var(--h#{$i}-size) - var(--body-line-height)*1rem)/2);
  }
}

.keyword {
  color: var(--keyword-blue);
  font-weight: var(--bold);
}

.proof {

  &-contents :last-of-type {
    margin-block-end: 0;
  }

  &__title {
    margin-block-end: 0;
  }

  & div.sketch {
    margin-block: var(--handrail-margin-block) var(--handrail-margin-block);
  }

}

.sketch p:last-of-type {
  padding-block-end: 1rem;
}

.theorem {

  &-contents :last-of-type {
    margin-block-end: 0;
  }

  > *:last-of-type {
    padding-block-end: 1rem;
  }

}

.definition {

  &-contents :last-of-type {
    margin-block-end: 0;
  }

  p:last-of-type {
    padding-block-end: 1rem;
  }

}

.step {
  margin-block-end: 1.25rem;

  &__number {
    display: none;
    color: var(--med-gray);
    position: absolute;
    left: calc(var(--handrail-offset) * 0.38);
    transform: translateX(-100%) translateX(-2em);
    font-family: 'Inconsolata', monospace;
  }

  &.last {
    padding-block-end: 1rem;
  }

}

.statement {
  max-width: inherit;
  margin-block-end: 0.25rem;

  & ol {
    margin-block: 0 0;
    padding-inline-start: 1.5rem;
  }

}

.author > p {
  margin: 0;
}

.topic#abstract dl,
.topic#author dl {
  display: grid;
  grid-template-columns: max-content auto;
  column-gap: 1em;
}

.topic#abstract dt,
.topic#author dt {
  text-align: right;
  font-weight: var(--bold);
}

dd > p, dt > p {
  margin-block-end: 0.25em;
}

.proof__header {
  display: flex;
  justify-content: space-between;
  border-bottom: var(--gray-200) solid 1px;
}

.proof__tabs {
  display: inherit;
}

.proof__tabs > button {
  border: none;
  background: var(--white);
  padding-inline: 1rem;
  font-size: 16px;
  color: var(--med-gray);
}

.proof__tabs > button.active {
  color: var(--link-color);
  box-shadow: 0px 10px 0px -5px var(--link-color);
}

.proof__tabs > button:hover {
  color: var(--link-color-hover);
  cursor: pointer;
}

ol.bibliography {
  padding-inline-start: var(--handrail-offset);

  & li {
    margin-block: 0.75rem;
  }

}

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

  &__number {
    color: var(--lgt-gray);
  }

  &:hover &__number {
    color: var(--drk-gray);
  }

  &__number--phantom {
    visibility: hidden;
  }

}

.note {

  &__content {
    display: none;
  }
}

table.table {
  margin-left: auto;
  margin-right: auto;
  text-align: center;
  border-collapse: collapse;
  margin-block: 1em;
}

tbody tr:nth-child(odd) {
  background: var(--gray-100);
}

tbody td.tabledatum {
  padding-inline: 1rem;
  padding-block: 0.5rem;
}

thead.tablehead td.tabledatum {
  padding-inline: 1rem;
  padding-block: 0.75rem;
}

thead.tablehead {
  border-top: var(--border-thin) solid var(--drk-gray);
  border-bottom: calc(var(--border-thin) / 2) solid var(--drk-gray);
}

tbody tr:last-child {
  border-bottom: var(--border-thin) solid var(--drk-gray);
}

table caption {
  caption-side: bottom;
  margin-block: 0.5rem;
}

// claimblocks should look like they are part of the preceding paragraph, if any
p:has(+.claimblock) {
  display: inline;
}
.claimblock {
  display: inline;

  & p {
    display: inherit;
  }
}


/* State */
/******************************************************************************************/

a:link, a:visited, a:active, a.note__link {
  text-decoration: none;
  color: var(--link-color);
  cursor: pointer;
}

a:hover, a.note__link:hover {
  text-decoration: underline;
  color: var(--link-color-hover);
}

.options .option:hover {
  text-shadow: 0 0 1px var(--lgt-gray);
  cursor: pointer;
  background: var(--drk-gray);
  color: var(--lgt-gray);
}

.handrail__btn:hover {
  background: var(--gray-900);
  color: var(--gray-200);
  cursor: pointer;

  & > span {
    text-shadow: 0 0 1px black;
  }

}

.handrail:hover > .handrail__btn-container,
.handrail:hover > .handrail__icons {
  display: flex;
}

.handrail:hover > .step__number {
  display: block;
}

.proof {

  &:not(.collapsed) {
    padding-bottom: 0;
  }

  &.collapsed > .proof__title {
    margin-block-end: 0;
  }

  & p:last-child {
    margin-block-end: 0;
  }

}

.step.narrow-before::before {
  content: "...";
}

.step.narrow-after::after {
  content: "...";
}

.error {
  background-color: pink;
}

// nodes that have been translated using the default visit_node have this class
.node-with-no-class {
  background-color: pink;
}


/* Theming */
/******************************************************************************************/

.tiny {
  font-size: 0.5rem;
}
.smallest {
  font-size: 0.7rem;
}
.smaller {
  font-size: 0.8rem;
}
.small {
  font-size: 0.9rem;
}
.normal {
  font-size: 1rem;
}
.large {
  font-size: 1.2rem;
}
.larger {
  font-size: 14.4rem;
}
.largest {
  font-size: 17.281rem;
}
.huge {
  font-size: 20.741rem;
}
.huger {
  font-size: 24.88rem;
}

.draft{
  color: blue;
}

.hilite {
  background-color: var(--hilite-color);
};

.handrail.stars-1,
.handrail.clocks-1 {
  border-width: 0 0 0 var(--border-thin);

  & .handrail__btn:last-of-type  {
    border-width: 0 0 0 var(--border-thin);
  }

  & .handrail__btn-container {
    transform: translateX(calc(-1 * var(--border-thin)));
  }

}

.handrail.stars-2,
.handrail.clocks-2 {
  border-width: 0 0 0 var(--border-med);

  & .handrail__btn:last-of-type  {
    border-width: 0 0 0 var(--border-med);
  }

  & .handrail__btn-container {
    transform: translateX(calc(-1 * var(--border-med)));
  }

}

.handrail.stars-3,
.handrail.clocks-3 {
  border-width: 0 0 0 var(--border-thick);

  & .handrail__btn:last-of-type  {
    border-width: 0 0 0 var(--border-thick);
  }

  & .handrail__btn-container {
    transform: translateX(calc(-1 * var(--border-thick)));
  }

}

.handrail.clocks-2 {
  border-color: var(--clock-color);

  & .handrail__btn:last-of-type  {
    border-color: var(--clock-color);
  }

}

.handrail.stars-2 {
  border-color: var(--star-color);

  & .handrail__btn:last-of-type  {
    border-color: var(--star-color);
  }

}

.handrail.clocks-3 {
  border-color: var(--clock-color);

  & .handrail__btn:last-of-type  {
    border-color: var(--clock-color);
  }

}

.handrail.stars-3 {
  border-color: var(--star-color);

  & .handrail__btn:last-of-type  {
    border-color: var(--star-color);
  }

}

.tooltipster-sidetip {

  & .tooltipster-box {
    background: var(--white)!important;
  }

  & .tooltipster-arrow-background {
    border-top-color: var(--white)!important;
  }

  & .tooltipster-content {
    color: var(--drk-gray)!important;
  }


}

span.code {
  font-family: monospace;
  white-space: pre;
  margin: 1em 0;
  background: var(--gray-100);
}

li.bibitem:hover > a.bibitem-doi {
  text-decoration: underline;
}

@media (min-width: 70em) {

  .manuscriptwrapper {
    box-shadow: 0 0 8px 10px #eee;
    margin: 2.5em auto;
  }

  a.bibitem-doi {
    float: right;
  }

}


@media (max-width: 48em) {

  :root {
    --h1-size: 2.488rem;
    --h2-size: 2.074rem;
    --h3-size: 1.728rem;
    --h4-size: 1.440rem;
    --h5-size: 1.200rem;
    --h6-size: 1.000rem;
    --side-padding: 1.5em;
    --font-size: 93.75%;
  }

  .options {
    left: 0;
    right: unset;
  }

  .options .option {
    text-align: start;
  }

  .handrail--offset {
    transform: none;
    width: 100%;
  }

  .handrail--nested {
    transform: translateX(calc(-1 * var(--handrail-offset) - var(--border-thin)));
    width: calc(100% + var(--handrail-offset) + var(--border-thin));
  }

  .handrail__icons {
    transform: unset;
    flex-direction: row;
    left: var(--handrail--offset);
    top: 0;
    gap: .25rem;
  }

  .fas:not(.handrail__icons-last) {
    display: none;
  }

  .handrail.stars-3 .handrail__icons--stars::before {content: '3x';}
  .handrail.stars-2 .handrail__icons--stars::before {content: '2x';}
  .handrail.stars-1 .handrail__icons--stars::before {content: '1x';}

  .handrail.clocks-3 .handrail__icons--clocks::before {content: '3x';}
  .handrail.clocks-2 .handrail__icons--clocks::before {content: '2x';}
  .handrail.clocks-1 .handrail__icons--clocks::before {content: '1x';}

}
