@tailwind base;
@tailwind components;
@tailwind utilities;

:root {
  --base-font-family: -apple-system, system-ui, 'Segoe UI', Helvetica, Arial, sans-serif,
    'Apple Color Emoji', 'Segoe UI Emoji';
  --base-colour: #24292e;
}

.full-screen {
  height: calc(100vh - 160px);
}

.drawer-height {
  height: calc(100vh - 4.5rem);
}

@screen md {
  .drawer-height {
    height: unset;
  }
}

.preview-width {
  width: 80vw;
}

.toggle-dark-mode {
  float: right;
}

@layer base {
  html {
    @apply bg-gray-50;
  }

  div {
    overscroll-behavior-y: contain;
  }

  .preview p {
    margin-bottom: 16px;
  }

  .preview h1 {
    box-sizing: border-box;
    color: var(--base-colour);
    font-family: var(--base-font-family);
    font-size: 2em;
    font-weight: 600;
    line-height: 1.25;
    margin: 24px 0 16px;
    padding-bottom: 0.3em;
    word-wrap: break-word;
    border-bottom: 1px solid #eaecef;
  }
  .preview h2 {
    box-sizing: border-box;
    color: var(--base-colour);
    font-family: var(--base-font-family);
    font-size: 1.5em;
    font-weight: 600;
    line-height: 1.25;
    margin-bottom: 16px;
    margin-top: 24px;
    padding-bottom: 0.3em;
    word-wrap: break-word;
    border-bottom: 1px solid #eaecef;
  }

  .preview h3 {
    box-sizing: border-box;
    color: var(--base-colour);
    font-family: var(--base-font-family);
    font-size: 1.2em;
    font-weight: 600;
    line-height: 1.25;
    margin-bottom: 16px;
    margin-top: 24px;
    padding-bottom: 0.3em;
    word-wrap: break-word;
    border-bottom: 1px solid #eaecef;
  }

  .preview h4 {
    box-sizing: border-box;
    color: var(--base-colour);
    font-family: var(--base-font-family);
    font-size: 1em;
    font-weight: 600;
    line-height: 1.25;
    margin-bottom: 16px;
    margin-top: 24px;
    word-wrap: break-word;
  }

  .preview td {
    border-collapse: collapse;
    box-sizing: border-box;
    color: var(--base-colour);
    font-family: var(--base-font-family);
    line-height: 24px;
    padding: 6px 13px;
    text-align: -webkit-left;
    word-wrap: break-word;
    border: 1px solid #dfe2e5;
  }

  .preview th {
    border-collapse: collapse;
    box-sizing: border-box;
    color: var(--base-colour);
    font-family: var(--base-font-family);
    font-weight: 600;
    line-height: 24px;
    padding: 6px 13px;
    text-align: -webkit-left;
    word-wrap: break-word;
    border: 1px solid #dfe2e5;
  }

  .preview tr {
    background-color: #fff;
    border-collapse: collapse;
    box-sizing: border-box;
    color: var(--base-colour);
    font-family: var(--base-font-family);
    line-height: 24px;
    overflow-wrap: break-word;
    word-wrap: break-word;
  }
  .preview tr :nth-child(2n) {
    background-color: #f6f8fa;
  }

  .preview thead {
    font-size: 16px;
    line-height: 1.5;
    word-wrap: break-word;
    border-spacing: 0;
    border-collapse: collapse;
    box-sizing: border-box;
  }

  .preview table {
    -webkit-border-horizontal-spacing: 0;
    -webkit-border-vertical-spacing: 0;
    border-collapse: collapse;
    box-sizing: border-box;
    color: var(--base-colour);
    display: block;
    font-family: var(--base-font-family);
    line-height: 24px;
    margin-bottom: 16px;
    margin-top: 0;
    max-width: 100%;
    overflow: auto;
    width: max-content;
    word-wrap: break-word;
  }

  .preview image {
    background-color: #fff;
    border-style: none;
    color: #0366d6;
    cursor: pointer;
    font-family: var(--base-font-family);
    line-height: 24px;
    max-width: 100%;
    word-wrap: break-word;
    margin-bottom: 16px;
  }

  .preview ul {
    box-sizing: border-box;
    color: var(--base-colour);
    font-family: var(--base-font-family);
    line-height: 24px;
    margin-bottom: 16px;
    margin-top: 0;
    padding-left: 2em;
    word-wrap: break-word;
  }

  .preview ul li {
    box-sizing: border-box;
    color: var(--base-colour);
    font-family: var(--base-font-family);
    line-height: 24px;
    margin-top: 0.25em;
    text-align: left;
    word-wrap: break-word;
    list-style: initial;
  }

  .preview ol li {
    box-sizing: border-box;
    color: var(--base-colour);
    font-family: var(--base-font-family);
    line-height: 24px;
    margin-top: 0.25em;
    text-align: left;
    word-wrap: break-word;
    list-style: decimal;
  }

  .preview pre {
    background-color: #f6f8fa;
    border-radius: 6px;
    box-sizing: border-box;
    color: var(--base-colour);
    font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 85%;
    line-height: 1.45;
    margin-bottom: 16px;
    margin-top: 0;
    overflow: auto;
    overflow-wrap: normal;
    padding: 16px;
    white-space: pre;
    word-break: normal;
  }

  code:not(.preview pre code) {
    background-color: rgba(27, 31, 35, 0.05);
    border-radius: 6px;
    box-sizing: border-box;
    color: var(--base-colour);
    font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 85%;
    line-height: 20.4px;
    margin: 0;
    padding: 0.2em 0.4em;
    word-wrap: break-word;
  }

  .preview a {
    box-sizing: border-box;
    color: #0366d6;
    cursor: pointer;
    font-family: var(--base-font-family);
    line-height: 24px;
    text-decoration: none;
    word-wrap: break-word;
  }

  .preview a :hover {
    outline: 0;
    text-decoration: underline;
  }
}

/** Dark mode styles **/
html.dark,
.dark body {
  background-color: rgba(38, 38, 38, var(--tw-bg-opacity));
}

html.dark .shadow {
  --tw-shadow: 0 1px 3px 0 rgb(255 255 255 / 79%), 0 1px 2px 0 rgba(255 255 255 / 79%);
  box-shadow: var(--tw-ring-offset-shadow, 0 0 #fff), var(--tw-ring-shadow, 0 0 #fff),
    var(--tw-shadow);
}

html.dark .md\:shadow-none {
  --tw-shadow: 0 0 #0000;
  box-shadow: var(--tw-ring-offset-shadow, 0 0 #fff), var(--tw-ring-shadow, 0 0 #fff),
    var(--tw-shadow);
}

html.dark ::-webkit-scrollbar {
  background-color: #454545;
  width: 10px;
}

html.dark ::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 20px;
}

html.dark ::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 20px;
}

html.dark ::-webkit-scrollbar-thumb:hover {
  background: #555;
}

html.dark .preview {
  background-color: rgba(38, 38, 38, var(--tw-bg-opacity));
  @apply text-white;
  margin-top: -3px;
}

html.dark .preview h1 {
  @apply text-white;
  border-bottom: 1px solid #eaecef;
}

html.dark .preview h2 {
  @apply text-white;
  border-bottom: 1px solid #eaecef;
}

html.dark .preview h3 {
  @apply text-white;
  border-bottom: 1px solid #eaecef;
}

html.dark .preview h4 {
  @apply text-white;
}

html.dark .preview td {
  @apply text-white;
  border-color: #a9b0b6;
}

html.dark .preview th {
  @apply text-white;
  border-color: #a9b0b6;
}

html.dark .preview tr {
  @apply text-white;
  background-color: rgba(38, 38, 38, var(--tw-bg-opacity));
}
html.dark .preview tr :nth-child(2n) {
  background-color: rgba(38, 38, 38, var(--tw-bg-opacity));
}

html.dark .preview table {
  @apply text-white;
}

html.dark .preview image {
  background-color: #fff;
  color: #3a91e1;
}

html.dark .preview ul {
  @apply text-white;
}

html.dark .preview ul li {
  @apply text-white;
}

html.dark .preview ol li {
  @apply text-white;
}

html.dark .preview pre {
  background-color: #6e768166;
  @apply text-white;
}

html.dark code:not(.preview pre code) {
  background-color: #6e768166;
  @apply text-white;
}

html.dark .preview a {
  color: #3a91e1;
}
