@layer highlight, base;

@layer base {
  html,
  body {
    padding: 0;
    margin: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-family: system-ui, -apple-system, Segoe UI, Roboto, Noto Sans, Ubuntu,
      Cantarell, Helvetica Neue, Helvetica, Arial, Verdana;
    color: var(--color-text-main);
    background: var(--color-background);
  }

  html {
    --color-background: #ffffff;
    --color-text-main: #060c26;
    --color-code: #c44545;
    --color-code-background: hsla(0, 56%, 96%, 0.78);
    --color-pre-background: #fafafa;
    --color-text-second: #717682;
    --color-line-gray: #e8e8eb;
    --color-link-active: #2071cc;
    --color-link-hover: #f3f6f8;
    --color-bg-light: #f8f7fa;
    --color-page-active: #ff1767;
    --color-input-primary: #f3f6f8;
    --color-input-border: #477cff;
    --color-code-bg: #252935;
    --color-code-main: #e1ebfe;
    --color-code-keyword: #ff6675;
    --color-code-class: #bf9dff;
    --color-code-variable: #69c6ff;
    --color-code-string: #81bcff;
    --color-code-params: #ffa259;
    --color-code-tag: #74e59d;
    --color-code-number: #ff6262;
    --color-code-comment: #6c7f93;
    --color-button-primary: #3389ff;
    --color-button-primary-hover: #2e7ae6;
    --color-button-primary-active: #296dcc;
    --color-button-secondary: #717682;
    --color-button-secondary-hover: #5d6068;
    --color-button-secondary-active: #4b4f5b;
    --color-button-warning: #ef5c5c;
    --color-button-warning-hover: #d65151;
    --color-button-warning-active: #bd4848;
    --color-success: #00e08f;
    --layout-padding-horizontal: 22px;
    --layout-padding-vertical: 30px;
    --layout-padding-content-horizontal: 50px;
    --layout-sidebar-width: 280px;
    --layout-width-main-col: 700px;
    --layout-height-header: 56px;
    --font-mono: Menlo, Monaco, Consolas, Courier New, monospace;
  }

  html.dark {
    --color-background: rgb(27, 27, 29);
    --color-text-main: rgb(227, 227, 227);
    --color-link-active: rgb(135, 175, 240);
    --color-code-background: #ffffff0f;
    --color-code: #ee1a1a;
    --color-button-secondary: #bec3c9;
    --color-input-primary: #474747;
    --color-pre-background: #0d1117;
  }

  * {
    box-sizing: border-box;
  }

  a {
    color: var(--color-link-active);
    /* color: #0070f3; */
    /* border-bottom: 1px solid #000; */
    padding-bottom: 1px;
    text-decoration: none;
  }

  a:hover {
    text-decoration: underline;
  }

  img {
    max-width: 100%;
    display: block;
  }

  h1,
  h2,
  h3,
  h4,
  h5,
  h6,
  p,
  table {
    padding: 10px 0;
  }

  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    cursor: text;
    line-height: 1.35em;
    margin: 10px 0 0;
    font-weight: 500;
  }

  h2 {
    font-size: 24px;
  }

  h3 {
    font-size: 18px;
  }

  p {
    margin: 0;
  }

  ol,
  ul {
    list-style: outside;
    margin: 0;
    padding-left: 40px;
  }

  ol {
    list-style-type: decimal;
  }

  li {
    padding: 0;
  }

  li:not(:last-of-type) {
    margin-bottom: 8px;
  }

  :not(pre) > code {
    background: var(--color-code-background);
    border-bottom: 0;
    color: var(--color-code);
    display: inline-block;
    font-family: Menlo, Monaco, Consolas, Courier New, monospace;
    font-family: var(--font-mono);
    font-size: 14px;
    font-size: 0.84em;
    letter-spacing: 0;
    line-height: 1.4em;
    margin: -1px 2px 0;
    padding: 3px 4px 2px;
  }

  a:hover code {
    text-decoration: underline;
  }

  pre code.hljs {
    font-family: Menlo, Monaco, Consolas, Courier New, monospace;
    font-family: var(--font-mono);
    font-size: 14px;
  }

  pre:has(code.hljs) {
    background-color: var(--color-pre-background);
    padding: 5px 10px;
    border-radius: 8px;
    overflow-x: auto;
    line-height: 1.5rem;
    /* white-space: pre-wrap; */
    /* ^ This will wrap the code, if needed */
  }

  hr {
    line-height: 1.6em;
    text-align: center;
    width: 100%;
    border: 0;
  }

  hr:before {
    content: "***";
    display: inline-block;
    font-size: 30px;
    height: 30px;
    letter-spacing: 0.2em;
    line-height: 65px;
  }

  table {
    border: 1px solid var(--color-line-gray);
    border-collapse: collapse;
    border-radius: 3px;
    table-layout: fixed;
    width: 100%;
  }

  table td,
  th {
    text-align: start;
    padding: 6px 8px;
    border: 1px solid var(--color-line-gray);
  }

  img {
    max-width: 100%;
    display: block;
    /* margin: 0 auto; */
    border-style: none;
  }

  article > header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    margin-bottom: 2rem;
  }

  article img {
    border: 1px solid #ddd;
    border-radius: 2px;
    box-shadow: 0 1px 1px hsl(0deg 0% 0% / 0.007),
      0 2px 2px hsl(0deg 0% 0% / 0.007), 0 4px 4px hsl(0deg 0% 0% / 0.007),
      0 8px 8px hsl(0deg 0% 0% / 0.007), 0 16px 16px hsl(0deg 0% 0% / 0.007);
    margin: 2rem 0;
  }

  header > h1 {
    font-size: 1.9rem;
    line-height: 150%;
  }

  main {
    margin: 5.5rem auto 3rem;
    line-height: 1.625;
    max-width: 768px;
    padding: 0 1rem;
    font-size: 1.1rem;
  }

  .date-header {
    color: var(--color-button-secondary);
    font-size: 14px;
  }

  .logo-container {
    display: flex;
    align-items: center;
    flex-direction: row;
    padding: 10px;
    border-radius: 500px;
    border: 2px solid var(--color-text-main);
    color: var(--color-text-main);
  }

  .logo-vector {
    width: 24px;
    height: 24px;
  }

  html.dark .logo-vector {
    filter: invert(1);
  }

  .global-header {
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 64px;
    border-bottom: 1px solid var(--color-input-primary);
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    flex-basis: 100%;
    background: var(--color-background);
  }

  .global-inner-header {
    width: 100%;
    margin: auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 768px;
    padding: 0 1rem;
    font-size: 1.1rem;
  }

  #dark-mode-toggle {
    height: 24px;
    width: 24px;
    cursor: pointer;
    outline: none;
    border: 0;
    background: none;
  }

  html.dark #dark-mode-toggle {
    filter: invert(1);
  }

  .article-list {
    list-style-type: none;
    padding-left: 0;
    padding-top: 1rem;
    & > li {
      padding: 0.4rem 0;
    }
  }

  .article-header {
    margin-bottom: 2rem;
  }

  .bio {
    display: flex;
    flex-direction: column;
    padding: 1rem 0 0.5rem 0;
    gap: 8px;
    & * {
      vertical-align: middle;
    }
    & svg {
      width: 16px;
      height: 16px;
    }
    > span {
      display: flex;
      align-items: center;
      gap: 8px;
    }
  }
}

@layer highlight {
  /* From https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.7.0/build/styles/github.min.css */

  html.light {
    .hljs {
      color: #24292e;
    }
    .hljs-doctag,
    .hljs-keyword,
    .hljs-meta .hljs-keyword,
    .hljs-template-tag,
    .hljs-template-variable,
    .hljs-type,
    .hljs-variable.language_ {
      color: #d73a49;
    }
    .hljs-title,
    .hljs-title.class_,
    .hljs-title.class_.inherited__,
    .hljs-title.function_ {
      color: #6f42c1;
    }
    .hljs-attr,
    .hljs-attribute,
    .hljs-literal,
    .hljs-meta,
    .hljs-number,
    .hljs-operator,
    .hljs-selector-attr,
    .hljs-selector-class,
    .hljs-selector-id,
    .hljs-variable {
      color: #005cc5;
    }
    .hljs-meta .hljs-string,
    .hljs-regexp,
    .hljs-string {
      color: #032f62;
    }
    .hljs-built_in,
    .hljs-symbol {
      color: #e36209;
    }
    .hljs-code,
    .hljs-comment,
    .hljs-formula {
      color: #6a737d;
    }
    .hljs-name,
    .hljs-quote,
    .hljs-selector-pseudo,
    .hljs-selector-tag {
      color: #22863a;
    }
    .hljs-subst {
      color: #24292e;
    }
    .hljs-section {
      color: #005cc5;
      font-weight: 700;
    }
    .hljs-bullet {
      color: #735c0f;
    }
    .hljs-emphasis {
      color: #24292e;
      font-style: italic;
    }
    .hljs-strong {
      color: #24292e;
      font-weight: 700;
    }
    .hljs-addition {
      color: #22863a;
      background-color: #f0fff4;
    }
    .hljs-deletion {
      color: #b31d28;
      background-color: #ffeef0;
    }
  }

  /* From https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.7.0/build/styles/github-dark.min.css */

  html.dark {
    .hljs {
      color: #c9d1d9;
    }
    .hljs-doctag,
    .hljs-keyword,
    .hljs-meta .hljs-keyword,
    .hljs-template-tag,
    .hljs-template-variable,
    .hljs-type,
    .hljs-variable.language_ {
      color: #ff7b72;
    }
    .hljs-title,
    .hljs-title.class_,
    .hljs-title.class_.inherited__,
    .hljs-title.function_ {
      color: #d2a8ff;
    }
    .hljs-attr,
    .hljs-attribute,
    .hljs-literal,
    .hljs-meta,
    .hljs-number,
    .hljs-operator,
    .hljs-selector-attr,
    .hljs-selector-class,
    .hljs-selector-id,
    .hljs-variable {
      color: #79c0ff;
    }
    .hljs-meta .hljs-string,
    .hljs-regexp,
    .hljs-string {
      color: #a5d6ff;
    }
    .hljs-built_in,
    .hljs-symbol {
      color: #ffa657;
    }
    .hljs-code,
    .hljs-comment,
    .hljs-formula {
      color: #8b949e;
    }
    .hljs-name,
    .hljs-quote,
    .hljs-selector-pseudo,
    .hljs-selector-tag {
      color: #7ee787;
    }
    .hljs-subst {
      color: #c9d1d9;
    }
    .hljs-section {
      color: #1f6feb;
      font-weight: 700;
    }
    .hljs-bullet {
      color: #f2cc60;
    }
    .hljs-emphasis {
      color: #c9d1d9;
      font-style: italic;
    }
    .hljs-strong {
      color: #c9d1d9;
      font-weight: 700;
    }
    .hljs-addition {
      color: #aff5b4;
      background-color: #033a16;
    }
    .hljs-deletion {
      color: #ffdcd7;
      background-color: #67060c;
    }
  }
}
