// Replace this with your own font imports!
@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;700&family=Inter:wght@400;600;700&family=Source+Sans+Pro:wght@400;600&display=swap');
:root {
  --font-body: "Source Sans Pro";
  --font-header: "Inter";
  --font-mono: "Fira Code"
}

// typography
html {
  scroll-behavior: smooth;
  &:lang(ar) {
    & p, & h1, & h2, & h3, article, header {
      direction: rtl;
      text-align: right;
    }
  }
  & footer > p {
    text-align: center !important;
  }
}

.singlePage {
  padding: 4em 30vw;
  margin: 0 auto;
  max-width: 1000px;
  @media all and (max-width: 1200px) {
    padding: 25px 5vw;
  }
}


body {
  margin: 0;
  height: 100vh;
  width: 100vw;
  max-width: 100%;
  box-sizing: border-box;
  background-color: var(--light);
}

h1, h2, h3, h4, h5, h6, thead {
  font-family: var(--font-header);
  color: var(--dark);
  font-weight: revert;
  margin: 2rem 0 0;
  padding: 2rem auto 1rem;

  &:hover > .hanchor {
    color: var(--secondary);
  }
}

.hanchor {
  font-family: var(--font-header);
  opacity: 0.8;
  transition: color 0.3s ease;
  color: var(--dark);
}

p, ul, text, a, tr, td, li, ol, ul {
  font-family: var(--font-body);
  color: var(--gray);
  fill: var(--gray);
  font-weight: revert;
  margin: revert;
  padding: revert;
}

tbody, li, p {
  line-height: 1.5em;
}

.mainTOC {
  border-radius: 5px;
  padding: 0.75em 0;

  & details {
    & summary {
      cursor: zoom-in;
      font-family: var(--font-header);
      color: var(--dark);
      font-weight: 700;
    }

    &[open] summary {
      cursor: zoom-out;
    }
  }
}

#TableOfContents > ol {
  counter-reset: section;
  margin-left: 0;
  padding-left: 1.5em;
  & > li {
    counter-increment: section;
    & > ol {
      counter-reset: subsection;
      & > li {
        counter-increment: subsection;
        &::marker {
          content: counter(section) "." counter(subsection) "  ";
        }
      }
    }
  }

  & > li::marker {
    content: counter(section) "  ";
  }

  & > li::marker, & > li > ol > li::marker {
    font-family: var(--font-body);
    font-weight: 700;
  }
}

table {
  border: 1px solid var(--outlinegray);
  width: 100%;
  padding: 1.5em;
  border-collapse: collapse;
}

td, th {
  padding: 0.2em 1em;
  border: 1px solid var(--outlinegray);
}

img {
  max-width: 100%;
  border-radius: 3px;
  margin: 1em 0;
}

p > img + em {
  display: block;
  transform: translateY(-1em);
}

sup {
  line-height: 0
}

blockquote {
  margin-left: 0;
  border-left: 3px solid var(--secondary);
  padding-left: 1em;
  transition: border-color 0.2s ease;
}

.footnotes p {
  margin: 0.5em 0;
}

.pagination {
  list-style: none;
  padding-left: 0;
  display: flex;
  margin-top: 2em;
  gap: 1.5em;
  justify-content: center;

  .disabled {
    opacity: 0.2;
  }

  & > li {
    text-align: center;
    display: inline-block;

    & a {
      background-color: transparent !important;
    }

    & a[href$="#"], &.active a {
      opacity: 0.2;
    }
  }
}

article {
  & > h1 {
    margin-top: 2em;
    font-size: 2em;
  }

  & > .meta {
    margin: 0 0 1em 0;
    opacity: 0.7;
  }

  & a {
    font-weight: 600;

    &.internal-link {
      text-decoration: none;
      background-color: transparentize(#8f9fa9, 0.85);
      padding: 0 0.1em;
      margin: auto -0.1em;
      border-radius: 3px;

      &.broken {
        opacity: 0.5;
        background-color: transparent;
      }
    }
  }

  & p {
    overflow-wrap: anywhere;
  }
}

.tags {
  list-style: none;
  padding-left: 0;

  & .meta {
    margin: 1.5em 0;
    & > h1 {
      margin: 0;
    }
    & > p {
      margin: 0;
    }
  }

  & > li {
    display: inline-block;
    margin: 0.4em 0.2em;
  }

  & > li > a {
    border-radius: 8px;
    border: var(--outlinegray) 1px solid;
    padding: 0.2em 0.5em;
    &::before {
      content: "#";
      margin-right: 0.3em;
      color: var(--outlinegray);
    }
  }
}

.backlinks a {
  font-weight: 600;
  font-size: 0.9rem;
}

sup > a {
  text-decoration: none;
  padding: 0 0.1em 0 0.2em;
}

#page-title {
  margin: 0;
  & > a {
    font-family: var(--font-header);
  }
}

a {
  font-size: 1em;
  font-weight: 700;
  text-decoration: none;
  transition: all 0.2s ease;
  color: var(--secondary);
  &:hover {
    color: var(--tertiary) !important;
  }
}

pre {
  font-family: var(--font-mono);
  padding: 0.75em;
  border-radius: 3px;
  overflow-x: scroll;
}

code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  padding: 0.15em 0.3em;
  border-radius: 5px;
  background: var(--lightgray);
}

@keyframes fadeIn {
  0% {opacity:0;}
  100% {opacity:1;}
}

footer {
  margin-top: 4em;
  text-align: center;
  & ul {
    padding-left: 0;
  }
}

hr {
  width: 100%;
  margin: 2em auto;
  height: 1px;
  border: none;
  background-color: var(--outlinegray);
}

.page-end {
  display: flex;
  flex-direction: row;
  gap: 2em;

  @media all and (max-width: 780px) {
    flex-direction: column;
  }

  & > * {
    flex: 1 0 0;
  }

  & > .backlinks-container {
    & > ul {
      list-style: none;
      padding: 0;
      margin: 0;

      & > li {
        margin: 0.5em 0;
        padding: 0.25em 1em;
        border: var(--outlinegray) 1px solid;
        border-radius: 5px
      }
    }
  }

  & #graph-container {
    border: var(--outlinegray) 1px solid;
    border-radius: 5px;
    box-sizing: border-box;
    min-height: 250px;
    margin: 0.5em 0;

    & > svg {
      margin-bottom: -5px;

    }
  }
}

.centered {
  margin-top: 30vh;
}

.spacer {
  flex: 1 1 auto;
}

header {
  display: flex;
  flex-direction: row;
  align-items: center;
  margin: 1em 0 2em;

  & > h1 {
    font-size: 2em;
  }

  & > nav {
    @media all and (max-width: 600px) {
      display: none;
    }
  }

  #search-icon {
    background-color: var(--lightgray);
    border-radius: 4px;
    height: 2em;
    display: flex;
    align-items: center;
    cursor: pointer;
    & > p {
      display: inline;
      padding: 0 1.5em 0 2em;
    }
  }

  & svg {
    cursor: pointer;
    width: 18px;
    min-width: 18px;
    margin: 0 0.5em;

    &:hover .search-path {
      stroke: var(--tertiary);
    }

    .search-path {
      stroke: var(--gray);
      stroke-width: 2px;
      transition: stroke 0.5s ease;
    }
  }
}

#search-container {
  position: fixed;
  z-index: 9999;
  left: 0;
  top: 0;
  width: 100vw;
  height: 100%;
  overflow: scroll;
  display: none;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);

  & > div {
    width: 50%;
    margin-top: 15vh;
    margin-left: auto;
    margin-right: auto;

    @media all and (max-width: 1200px) {
      width: 90%;
    }

    & > * {
      width: 100%;
      border-radius: 4px;
      background: var(--light);
      box-shadow: 0 14px 50px rgba(27, 33, 48, 0.12), 0 10px 30px rgba(27, 33, 48, 0.16);
      margin-bottom: 2em;
    }

    & > input {
      box-sizing: border-box;
      padding: 0.5em 1em;
      font-family: var(--font-body);
      color: var(--dark);
      font-size: 1.1em;
      border: 1px solid var(--outlinegray);

      &:focus {
        outline: none;
      }
    }

    & > #results-container {
      & .result-card {
        padding: 1em;
        cursor: pointer;
        transition: background 0.2s ease;
        border: 1px solid var(--outlinegray);
        border-bottom: none;
        width: 100%;

        // normalize button props
        font-family: inherit;
        font-size: 100%;
        line-height: 1.15;
        margin: 0;
        overflow: visible;
        text-transform: none;
        text-align: left;
        background: var(--light);
        outline: none;

        &:hover, &:focus {
          background: rgba(180, 180, 180, 0.15);
        }

        &:first-of-type {
          border-top-left-radius: 5px;
          border-top-right-radius: 5px;
        }

        &:last-of-type {
          border-bottom-left-radius: 5px;
          border-bottom-right-radius: 5px;
          border-bottom: 1px solid var(--outlinegray);
        }

        & > h3, & > p {
          margin: 0;
        }
      }
    }
  }
}

.search-highlight {
  background-color: #afbfc966;
  padding: 0.05em 0.2em;
  border-radius: 3px;
}

.section-ul {
  list-style: none;
  margin-top: 2em;
  padding-left: 0;

}

.section-li {
  margin-bottom: 1em;

  & > .section {
    display: flex;
    align-items: center;

    @media all and (max-width: 600px) {
      & .tags {
        display: none;
      }
    }

    & h3 > a {
      font-weight: 700;
      margin: 0;
    }

    & p {
      margin: 0;
      padding-right: 1em;
      flex-basis: 6em;
    }
  }

  & h3 {
    opacity: 1;
    font-weight: 700;
    margin: 0;
  }

  & .meta {
    opacity: 0.6;
  }
}

@keyframes dropin {
  0% {
    display: none;
    opacity: 0;
    visibility: hidden;
  }
  1% {
    display: inline-block;
    opacity: 0;
  }
  100% {
    opacity: 1;
    visibility: visible;
  }
}

.popover {
  z-index: 999;
  position: absolute;
  width: 20rem;
  display: none;
  background-color: var(--light);
  padding: 1rem;
  margin: 1rem;
  border: 1px solid var(--outlinegray);
  border-radius: 5px;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  user-select: none;
  overflow-wrap: anywhere;
  box-shadow: 6px 6px 36px 0 rgba(0,0,0,0.25);

  @media all and (max-width: 600px) {
    display: none !important;
  }

  &.visible {
    opacity: 1;
    visibility: visible;
    display: inline-block;
    animation: dropin 0.2s ease;
  }

  & > h3 {
    font-size: 1rem;
    margin: 0.25rem 0;
  }

  & .meta {
    margin-top: 0.25rem;
    opacity: 0.5;
    font-family: var(--font-mono);
    font-size: 0.8rem;
  }

  & > p {
    margin: 0;
    padding: 0.5rem 0;
  }

  & > p, & > a {
    font-size: 1rem;
    font-weight: 400;
    user-select: none;
  }
}

#contact_buttons ul {
  list-style-type: none;

  li {
    display: inline-block;
  }

  li a {
    padding: 0 1em;
  }
}

mark {
  background-color: var(--highlighted);
  color: var(--gray);
}
