/* ./design-system.css */

body {
  /* Layout */
  --c-text-bg: #fcfcfd;
  /* Mark */
  --c-text-mark: #b8632a;
  --c-bg-mark: #df7b39;
  --c-bg-mark-active: #89491e;
  --c-text-on-mark-bg: white;
  /* Headers */
  --c-bg-h: #bceafa7a;
  --c-border-h: #4ccbf6;
  /* Text */
  --c-text-default: #000;
  /* Secondary */
  --c-text-secondary: #555;
  --c-border-secondary: #c0c0c09c;
  /* Inputs */
  --c-border-active: #89491e;
  /* Links */
  --c-text-link: var(--c-text-mark);
  --c-text-link-visited: #197eaf;
  /* Custom UI */
  --c-menu-active-bg: #3f000021;
  --border-dashed: 0.25rem solid transparent;
  --image-border-dashed: repeating-linear-gradient(
      to right,
      var(--c-border-secondary) 0 8px,
      transparent 8px 12px
    )
    27;
  --size-border-pagination: 0.125rem;
  --size-border-header: 0.125rem;
  /* Tables */
  --c-bg-th: #ffe2ce;
  --c-border-th: #b56b3a;
}


/* ./icons.css */

@font-face {
  font-family: "fontawesome-icons";
  src: url("/static/icons.woff2?9") format("woff2");
}

.icon:before,
.icon:before {
  font-family: fontawesome-icons !important;
  font-style: normal;
  font-weight: normal !important;
  font-variant: normal;
  text-transform: none;
  line-height: 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.icon-trash:before {
    content: "\f101";
}
.icon-scissor:before {
    /* Keep consistent with the "read more"'s css. */
    content: "\f102";
}
.icon-rss:before {
    content: "\f103";
}
.icon-quotes:before {
    /* Keep consistent with bookmark's css. */
    content: "\f104";
}
.icon-plus:before {
    content: "\f105";
}
.icon-pen-to-square:before {
    content: "\f106";
}
.icon-magnifying-glass:before {
    content: "\f107";
}
.icon-gear:before {
    content: "\f108";
}
.icon-eye:before {
    content: "\f109";
}
.icon-copy:before {
    content: "\f10a";
}
.icon-circle-check:before {
    content: "\f10b";
}
.icon-bookmark:before {
    content: "\f10c";
}
.icon-ban:before {
    content: "\f10d";
}
.icon-arrow-right:before {
    /* Keep consistent with pagination's css. */
    content: "\f10e";
}

/* ./content.css */

/* ./md.css */

.article-content {
  overflow: hidden; /* To properly handle .float-* */
  font-size: 1.15rem;
  line-height: 1.3;

  & a {
    color: var(--c-text-link);

    &:hover {
      filter: brightness(1.1);
    }

    &:visited {
      color: var(--c-text-link-visited);
    }
  }

  > p:last-child,
  > ul:last-child,
  > pre:last-child {
    margin-bottom: 0;
  }

  & blockquote {
    margin: 0 0 1rem 0;
    padding: 0 0 0 4rem;
    position: relative;
    font-style: italic;
    color: var(--c-text-secondary);

    &:before {
      content: "\f104";
      position: absolute;
      left: 0;
      top: 0.5rem;
      color: var(--c-bg-mark);
      font-size: 2.5rem;
      font-style: normal;
      font-family: "fontawesome-icons";
      opacity: 0.7;
    }

    p {
      margin: 0;
      padding: 0;
    }

    p + p {
      margin-top: 1rem;
    }

    & > p:last-child {
      margin-bottom: 0.5rem;
      padding-bottom: 0.5rem;
      border-bottom: var(--border-dashed);
      border-image: var(--image-border-dashed);
    }

    & > ul:last-child {
      margin: 0.5rem 0 0;
      padding: 0.5rem 0 0;
      border-top: var(--border-dashed);
      border-image: var(--image-border-dashed);

      & > li {
        list-style-type: none;
        padding: 0;
        margin: 0;
        font-style: normal;
        text-align: right;
        color: var(--c-bg-mark);
        font-weight: bold;
      }
    }

    /* Potentially too small 1-lines */
    &:has(> p:first-child:last-child) {
      padding-left: 2.5rem;

      &:before {
        font-size: 1.5rem;
      }
    }
  }

  & .embed-youtube {
    width: 100%;
    aspect-ratio: 1.777;
  }

  & pre {
    font-size: 1rem;
    padding: 0.8rem;
    border-radius: 0.5rem;
    tab-size: 2;
    overflow-x: auto;

    & .code-ln {
      color: #fefefe57;
      padding-right: 0.9rem;
      user-select: none;

      &::before {
        content: attr(data-idx);
      }
    }
  }

  & code {
    color: var(--c-text-mark);
    font-weight: 600;
  }

  & .float-right {
    float: right;
    margin: 0 0 1rem 1rem;
  }

  & .float-left {
    float: left;
    margin: 0 1rem 1rem 0;
  }

  & table {
    border: 1px solid var(--c-border-th);
    border-collapse: collapse;
  }
  & th {
    background: var(--c-bg-th);
    font-weight: bold;
    padding: 0.3rem 0.5rem;
    border: 1px solid var(--c-border-th);
  }
  & td {
    padding: 0.3rem 0.5rem;
    border: 1px solid var(--c-border-th);
  }

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



.article_list {
  margin: 1rem 0;
}

article + article {
  margin-top: 2.5rem;
}

.article-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}
@media (width <= 980px) {
  .article-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

.article-title {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.9rem;
  font-size: 1.5rem;
  color: inherit;

  & > .icon {
    color: var(--c-bg-mark);
    vertical-align: middle;
    transform: translateY(0.2rem);
    display: inline-block;
  }

  & > a {
    color: inherit;
    text-decoration: none;
  }

  &:hover {
    .icon {
      color: var(--c-bg-mark-active);
    }

    a {
      color: var(--c-text-mark);
    }
  }
}

.article-meta {
  display: flex;
  flex-direction: column;
  text-align: right;

  & .article-parent {
    text-decoration: none;
    color: var(--c-text-mark);
    font-weight: bold;

    &:hover {
      filter: brightness(1.3);
    }
  }

  & .article-date {
    font-style: italic;
    color: var(--c-text-secondary);
    white-space: nowrap;
  }
}
@media (width <= 980px) {
  .article-meta {
    flex-direction: row;
    margin-top: 0.5rem;

    & > *:nth-child(2n):before {
      content: "•";
      font-weight: bold;
      margin: 0 0.7rem;
      color: var(--c-text-secondary);
    }
  }
}

.article-read-more {
  margin: 0 0 1rem;
  display: flex;
  justify-content: center;
  border-bottom: var(--border-dashed);
  border-image: var(--image-border-dashed);
  text-decoration: none;
  color: var(--c-text-secondary);

  &:hover {
    color: var(--c-text-mark);
  }

  & .article-scissors {
    color: inherit;
    text-decoration: none;
    padding: 0rem 3rem;
    display: flex;
    gap: 1rem;
    align-items: center;
    background: var(--c-text-bg);
    transform: translateY(50%);

    &:before {
      content: "\f102";
      font-size: 2.4rem;
      font-family: "fontawesome-icons";
    }
  }
}

.pagination {
  --shift: 0.9rem;
  --padding: calc(var(--shift) + 0.4rem);

  margin: 0 0.2rem;
  display: flex;
  gap: 1rem;
  padding-top: 1rem;

  & .pagination-filler {
    flex: 1 1 auto;
  }

  & > a {
    flex: 0 0 auto;
    position: relative;
    display: inline-block;
    padding: 0.3rem 0.5rem;
    border: var(--size-border-pagination) solid var(--c-text-secondary);
    border-radius: 0.3rem;
    color: var(--c-text-secondary);
    text-transform: uppercase;
    text-decoration: none;
    font-family: monospace;
    font-weight: bold;
    font-size: 1.06rem;

    &:focus-visible {
      outline: none;
    }

    &:hover,
    &:focus-visible {
      color: var(--c-text-link);
      border-color: var(--c-text-link);
    }

    &.pagination-prev {
      padding-left: var(--padding);

      &:before {
        transform: translateY(-50%) scaleX(-1);
        left: calc(-1 * var(--shift));
      }
    }

    &.pagination-next {
      padding-right: var(--padding);

      &:before {
        right: calc(-1 * var(--shift));
      }
    }

    &:before {
      content: "\f10e";
      position: absolute;
      top: 50%;
      transform: translateY(-50%);
      background: var(--c-text-bg);
      font-weight: bold;
      font-size: 1.6em;
      line-height: 40%;
      font-family: "fontawesome-icons";
    }
  }
}

.article-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;

  & > a {
    display: inline-block;
    /* text */
    color: inherit;
    line-height: 1.87rem;
    padding: 0 1rem;
    font-weight: 500;
    text-decoration: none;
    /* bg */
    background: #abe5fc;
    background-clip: padding-box;
    /* border */
    border-style: solid;
    border-width: 0 0.6324rem; /* top right bottom left */
    border-color: transparent; /* image paints the border */
    border-image-source: url(/static/images/tag.svg);
    border-image-slice: 0 40.119 0 40.119;
    border-image-repeat: stretch;

    &:hover,
    &:focus-visible {
      filter: brightness(1.1);
      outline: none;
    }
  }
}

.article-footer {
  margin: 1.5rem 0 0;
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  border-top: var(--border-dashed);
  border-image: var(--image-border-dashed);
  padding: 1rem 0 0;

  & .article-tags {
    flex: 1 1 auto;
  }

  & .article-actions {
    flex: 0 0 auto;
  }
}

.article-actions {
  display: flex;
  gap: 1rem;

  & a,
  & button {
    border: 0;
    padding: 0;
    outline: none;
    background: transparent;
    text-decoration: none;
    color: var(--c-text-mark);
    font-size: 1.3rem;

    &:focus-visible,
    &:hover,
    &:active,
    &:focus {
      cursor: pointer;
      filter: brightness(1.3);
      outline: none;
    }
  }
}


/* ./menu.css */

.menu {
  flex: 1 1 auto;
  display: flex;
  gap: 0.5rem;
  margin: 0;
  padding: 0;

  & li {
    display: inline-block;
    background: var(--c-bg-mark);
    color: var(--c-text-on-mark-bg);
    border-top-left-radius: 0.2rem;
    border-top-right-radius: 0.2rem;
    position: relative;
    box-shadow: -2px -1px 3px 2px var(--c-menu-active-bg);

    &:hover:not(.active) {
      filter: brightness(1.2);
    }

    &.active {
      background: var(--c-bg-mark-active);
      font-weight: bold;

      &::after {
        content: "";
        display: inline-block;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        height: 0.4rem;
        background-color: var(--c-bg-mark-active);
        filter: brightness(0.9);
      }
    }

    & > a {
      display: inline-block;
      color: inherit;
      text-transform: none;
      text-decoration: none;
      font-size: 1rem;
      padding: 0.4rem 0.5rem;
    }
  }
}
@media (width <= 980px) {
  .menu {
    flex-wrap: wrap;
    max-width: 100%;

    & li {
      padding: 0.4rem 0.7rem;
      max-width: 100%;

      &::after {
        display: none !important;
      }
    }
  }
}

/* ./bg.css */

.page-clouds {
  position: fixed;
  right: 0;
  bottom: 0;
  pointer-events: none;
}
@media (width >= 1600px) {
  .page-clouds {
    zoom: 1.2;
  }
}
@media (width >= 2100px) {
  .page-clouds {
    zoom: 1.6;
  }
}

.page-hg {
  position: fixed;
  right: calc(50vw + 3rem + ((55rem) / 2));
  top: 5rem;
  pointer-events: none;

  & img {
    zoom: 0.4;
  }
}
@media (width >= 1600px) {
  .page-hg img {
    zoom: 0.5;
  }
}
@media (width >= 2100px) {
  .page-hg img {
    zoom: 0.7;
  }
}



body {
  padding: 0;
  margin: 0;
  color: var(--c-text-default);
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica,
    Arial, "Roboto", sans-serif;
  background: center / 100% 100% no-repeat fixed
    url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCnByZXNlcnZlQXNwZWN0UmF0aW89Im5vbmUiCnZpZXdCb3g9IjAgMCAxMDAgMTAwIj4KICA8ZGVmcz4KICAgIDxsaW5lYXJHcmFkaWVudCBpZD0iYSIgeDE9IjEwMCUiIHgyPSIwJSIgeTE9IjAlIiB5Mj0iMTAwJSIgZ3JhZGllbnRVbml0cz0ib2JqZWN0Qm91bmRpbmdCb3giPgogICAgICA8c3RvcCBvZmZzZXQ9IjAlIiBzdG9wLWNvbG9yPSIjZmZmIi8+CiAgICAgIDxzdG9wIG9mZnNldD0iMTAwJSIgc3RvcC1jb2xvcj0iIzY2Y2NmNiIvPgogICAgPC9saW5lYXJHcmFkaWVudD4KICA8L2RlZnM+CiAgPHJlY3QgeD0iMCIgd2lkdGg9IjEwMCUiIHk9IjAiIGhlaWdodD0iMTAwJSIgZmlsbD0idXJsKCNhKSIvPgo8L3N2Zz4=);
}

#page {
  position: relative;
  margin: 3.5rem auto 2rem;
  padding: 0rem 1.5rem 1.5rem 4rem;
  max-width: 50rem;
  background: var(--c-text-bg);
  border-radius: 1rem;
  box-shadow: -6px -2px 5px 2px #a7d2e6b3, 0px 2px 7px 1px #c0d6e0;

  &:before {
    content: "";
    position: absolute;
    display: block;
    width: 4.0625rem;
    height: 100%;
    max-height: var(--spiral-h); /* Set by JS */
    right: calc(100% - 2.1875rem);
    top: 1.2rem;
    bottom: 2rem;
    background-image: url(/static/images/spiral.svg);
    background-size: 100%;
    background-repeat: repeat-y;
  }
}

.page-header {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  transform: translateY(-2rem);
  margin-bottom: -0.2rem;

  & .icon {
    text-decoration: none;
    color: var(--c-text-mark);
    font-size: 1.3rem;

    &:hover {
      cursor: pointer;
      filter: brightness(1.3);
    }
  }
}

#search-bar {
  display: none;
  height: 1.3rem;
  box-sizing: border-box;
  font-size: 1.125rem;
  width: 20ex;
  border: 1px solid var(--c-border-active);
  border-radius: 0.2rem;
  padding: 0 0.5rem;

  &.visible {
    display: block;
  }

  &:focus,
  &:active {
    border-color: var(--c-border-active);
    outline: none;
  }
}

.page-title-container {
  margin: 0;
  display: flex;
  gap: 2rem;
  padding: 0;
  justify-content: space-between;
  align-items: center;
}

.page-title {
  display: inline-block;
  background: var(--c-bg-h);
  padding: 0.3rem 0.8rem;
  margin: 0 -0.8rem;
  border-radius: 0.3rem;
  border: var(--size-border-header) dashed var(--c-border-h);
}

.page-meta {
  display: flex;
  flex-direction: column;
  text-align: right;
}
.page-meta-parent {
  text-decoration: none;
  color: var(--c-text-mark);
  font-weight: bold;
}
.page-meta-date {
  font-style: italic;
  color: var(--c-text-secondary);
  white-space: nowrap;
}

.search-results {
  margin-top: 1rem;

  & + .pagination {
    margin-top: 1.5rem;
  }
}

.search-hl {
  color: var(--c-bg-mark);
  font-weight: bold;
  background: transparent;
}

@media (width <= 980px) {
  body {
    margin: 0;
    padding: 0;
    background: var(--c-text-bg);
  }

  .page-clouds {
    display: none;
  }

  #page {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    margin: 0;
    padding: 0 2rem 2rem;
    border-radius: 0;
    box-shadow: none;

    &:before {
      display: none;
    }
  }

  .page-header {
    padding: 1rem 0 1.5rem;
    margin: 0 -1rem;
    transform: none;

    .icon {
      display: none;
    }
  }

  .page-title-container {
    flex-direction: column;
    gap: 0;
    align-items: flex-start;

    & .page-meta {
      flex-direction: row;
      margin-top: 0.5rem;

      & > *:nth-child(2n):before {
        content: "•";
        font-weight: bold;
        margin: 0 0.7rem;
        color: var(--c-text-secondary);
      }
    }
  }
}

.page-emoji-p {
  margin: 1rem 0 0;
  font-size: 4rem;
  color: var(--c-border-secondary);
}
