html {
  scroll-behavior: smooth;
  scroll-padding: 2em;
}

body {
  font-family: var(--font-family);
  background: var(--background);
  color: var(--color);
  display: flex;
  flex-direction: column;
  min-height: 100svh;
}

#site-header {
  display: grid;
  grid-template-columns: 2fr 1fr;
  grid-template-rows: repeat(3, var(--site-header-height));
}

#site-header-menu, #site-header-search {
  grid-column: 1 / 3;
}

#site-footer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: repeat(3, var(--site-footer-height));
}

#site-footer-copyright, #site-footer-love {
  grid-column: 1 / 3;
}

#site-main-content-wrapper {
  display: flex;
  flex: 1;
}

#sidebar, #toc, #article-nav, #sidebar .btn-close, #toc .btn-close {
  display: none;
}

main {
  flex: 1;
  display: flex;
  overflow: auto;
}

#article {
  flex: 1;
  width: 100vw;
}

#sidebar {
  width: 85%;
  left: -85%;
}

#toc {
  width: 85%;
  right: -85%;
}

/* Small Tablet */
@media (min-width: 768px) and (max-width: 1023px) {
  #site-header {
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: repeat(2, var(--site-header-height));
  }

  #site-header-brand {
    grid-column: 1 / 6;
  }

  #site-header-controls {
    grid-column: 6 / 7;
  }

  #site-header-menu {
    grid-column: 1 / 5;
  }

  #site-header-search {
    grid-column: 5 / 7;
  }

  #site-footer {
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(2, var(--site-footer-height));
  }

  #site-footer-copyright {
    grid-column: 1 / 3;
  }

  #site-footer-social {
    grid-column: 3 / 4;
  }

  #site-footer-fund {
    grid-column: 4 / 5;
  }

  #site-footer-love {
    grid-column: 1 / 5;
  }

  #sidebar {
    width: 50%;
    left: -50%;
  }

  #toc {
    width: 50%;
    right: -50%;
  }
}

/* From Large Tablet */
@media (min-width: 1024px) {
  #site-header {
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: var(--site-header-height);
  }

  #site-header-brand {
    grid-column: 1 / 2;
  }

  #site-header-menu {
    grid-column: 2 / 5;
    grid-row: 1;
  }

  #site-header-search {
    grid-column: 5 / 6;
    grid-row: 1;
  }

  #site-header-controls {
    grid-column: 6 / 7;
  }

  #site-footer {
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: var(--site-footer-height);
  }

  #site-footer-copyright {
    grid-column: 1 / 3;
  }

  #site-footer-love {
    grid-column: 3 / 4;
    grid-row: 1;
  }

  #site-footer-social {
    grid-column: 4 / 5;
  }

  #site-footer-fund {
    grid-column: 5 / 6;
  }

  #article-nav-toc-btn {
    display: none;
  }
}

/* Large Tablet */
@media (min-width: 1024px) and (max-width: 1279px) {
  #sidebar {
    width: 33%;
    left: -33%;
  }

  #article {
    width: 75vw;
  }

  #toc {
    width: 25%;
    display: flex;
    flex-direction: column;
  }

  #toc .sticky {
    position: fixed;
    right: 0;
    width: 25%;
  }
}

/* From Desktop */
@media (min-width: 1280px) {
  #sidebar {
    width: 20%;
    display: flex;
    flex-direction: column;
  }

  #article {
    width: 60vw;
  }

  #toc {
    width: 25%;
    display: flex;
    flex-direction: column;
  }

  #sidebar .sticky {
    position: fixed;
    left: 0;
    width: 20%;
  }

  #toc .sticky {
    position: fixed;
    right: 0;
    width: 20%;
  }
}

/* Upto Large Tablet */
@media (max-width: 1023px) {
  #toc {
    position: fixed;
    top: 0;
    height: 100%;
    transition: .3s;
    z-index: 300;
    overflow-x: auto;
    background: var(--background);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
  }

  :root[data-color="dark"] #toc, :root[data-color="night"] #toc {
    box-shadow: 0 4px 30px rgba(255, 255, 255, 0.1);
  }

  .offcanvas-toc-on #toc {
    animation: slide-in-right .3s forwards;
    display: flex;
    flex-direction: column;
    padding-left: 16px;
    z-index: 10;
    cursor: default;
  }

  .offcanvas-toc-on:before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
  }

  .offcanvas-toc-on #toc .btn-close {
    display: block;
    position: absolute;
    top: 10px;
    left: 10px;
  }

  #article-nav-toc-btn {
    display: flex;
    box-shadow: var(--box-shadow2);
    border-radius: 6px;
    padding: 6px;
    cursor: pointer;
    white-space: nowrap;
    gap: 6px;
    color: var(--color2);
  }
}

/* Upto Desktop */
@media (max-width: 1279px) {
  #sidebar {
    position: fixed;
    top: 0;
    height: 100%;
    transition: .3s;
    z-index: 200;
    overflow-x: auto;
    background: var(--background);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
  }

  :root[data-color="dark"] #sidebar, :root[data-color="night"] #sidebar {
    box-shadow: 0 4px 30px rgba(255, 255, 255, 0.1);
  }

  .offcanvas-sidebar-on #sidebar {
    animation: slide-in-left .3s forwards;
    display: flex;
    flex-direction: column;
    z-index: 10;
    cursor: default;
  }

  .offcanvas-sidebar-on:before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
  }

  .offcanvas-sidebar-on #sidebar .btn-close {
    display: block;
    position: absolute;
    top: 10px;
    right: 10px;
  }

  #article-nav {
    display: flex;
    gap: 12px;
    overflow: auto;
    justify-content: space-between;
    height: var(--site-header-height);
    align-items: center;
    padding: 0 2px;
  }

  #article-nav-menu-btn {
    display: flex;
    box-shadow: var(--box-shadow2);
    border-radius: 6px;
    padding: 6px;
    cursor: pointer;
    white-space: nowrap;
    gap: 6px;
    color: var(--color2);
  }
}

body.offcanvas-sidebar-on, body.offcanvas-toc-on {
  cursor: pointer;
  overflow: hidden;
}

.offcanvas-sidebar-on:before, .offcanvas-toc-on:before {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
}

@keyframes slide-in-left {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(100%);
  }
}

@keyframes slide-in-right {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(-100%);
  }
}

:root {
  --site-header-height: 46px;
  --site-footer-height: 46px;
}

@media (min-width: 1025px) and (max-width: 1280px),
(min-width: 1024px) and (max-width: 1280px) and (orientation: portrait) {
  :root {
    --site-header-height: 60px;
    --site-footer-height: 60px;
  }
}

@media (min-width: 1281px) {
  :root {
    --site-header-height: 80px;
    --site-footer-height: 80px;
  }
}