/* style.css */
/***** THEME *****/

:root {
  --pico-font-size: 1rem;
  --pico-accordion-open-summary-color: #fff;

  --rd-bg: rgb(19, 22.5, 30.5);
  --rd-surface: #181c25;
  --rd-border: #2a2f3a;
  --rd-border-hover: #3d4452;
  --rd-muted: #8b93a3;
  --rd-header-height: 3.75rem;
}
html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--rd-header-height) + 1rem);
}

/***** LAYOUT *****/

@media (min-width: 1024px) {
  .container {
    max-width: 1000px;
  }
}

@media (min-width: 1280px) {
  .container {
    max-width: 1200px;
  }
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background-color: var(--rd-bg);
}

header, main, footer {
  position: relative;
  z-index: 2;
}

main {
  flex: 1;
  overflow: visible;
  padding: 1rem;
}


/* components/alerts.css */
.markdown-alert {
  padding: 1rem 1rem 0 1rem;
  border: 5px solid black;
  border-radius: 5px;

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

  .markdown-alert-title {
    margin: -1rem -1rem 1rem -1rem;
    padding: 0 0 5px 5px;
    text-shadow: 1px 1px 1px rgb(19, 22.5, 30.5);
    font-weight: bold;
    text-transform: uppercase;
    background-color: black;
  }

  &.markdown-alert-note {
    border-color: #004789;
    .markdown-alert-title {
      background-color: #004789;
    }
  }
  &.markdown-alert-tip {
    border-color: #008920;
    .markdown-alert-title {
      background-color: #008920;
    }
  }
  &.markdown-alert-important {
    border-color: #5e0089;
    .markdown-alert-title {
      background-color: #5e0089;
    }
  }
  &.markdown-alert-warning {
    border-color: #cd6000;
    .markdown-alert-title {
      background-color: #cd6000;
    }
  }
  &.markdown-alert-caution {
    border-color: #cd0000;
    .markdown-alert-title {
      background-color: #cd0000;
    }
  }
}


/* components/background.css */
#background {
  position: absolute;
  z-index: 1;
  top: 0;
  right: 0;
  left: 0;

  background-image:
    linear-gradient(to bottom, rgba(26, 26, 26, 0) 0%, var(--rd-bg) 100%),
    url('/assets/background.png');

  background-repeat: repeat-x;
  height: 770px;

  .section-pages & {
    height: 175px;
  }
  .section-gems &,
  .section-404 & {
    height: 320px;
  }

  /* Glow: a blurred copy of the letters screened on top, so only lit pixels bloom. */
  &::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url('/assets/background.png');
    background-repeat: repeat-x;
    filter: blur(4px) brightness(1.8);
    /* Fade out before the bottom edge so the bloom doesn't leave a seam. */
    mask-image: linear-gradient(to bottom, #000 0%, transparent 90%);
    mix-blend-mode: screen;
    pointer-events: none;
  }

  /* CRT: rolling scan band, scanlines and vignette, layered above the glow. */
  .section-home &::before {
    content: '';
    position: absolute;
    z-index: 1;
    inset: 0;
    background-image:
      linear-gradient(to bottom, transparent 0%, rgba(120, 200, 255, 0.06) 50%, transparent 100%),
      repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.35) 0 1px, transparent 1px 3px),
      radial-gradient(ellipse at center, transparent 50%, rgba(0, 0, 0, 0.6) 100%);
    background-size: 100% 160px, auto, auto;
    background-repeat: no-repeat, repeat, no-repeat;
    mask-image: linear-gradient(to bottom, #000 0%, transparent 90%);
    pointer-events: none;
    animation: crt-roll 16s linear infinite, crt-flicker 0.15s steps(2) infinite;

    @media (prefers-reduced-motion: reduce) {
      animation: none;
    }
  }
}

@keyframes crt-roll {
  from { background-position: 0 -160px, 0 0, 0 0; }
  to { background-position: 0 770px, 0 0, 0 0; }
}

@keyframes crt-flicker {
  from { opacity: 1; }
  to { opacity: 0.92; }
}


/* components/cards.css */
#cards {
  margin-bottom: 2rem;
  @media (min-width: 768px) {
    grid-template-columns: repeat(2, 1fr);
  }
  @media (min-width: 1024px) {
    grid-template-columns: repeat(3, 1fr);
  }
  .card {
    display: flex;
    flex-direction: column;
    margin-bottom: 0;
    border: 1px solid var(--rd-border);
    border-radius: 5px;
    background-color: var(--rd-surface);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    transition: border-color 0.2s, box-shadow 0.2s;

    &:hover {
      border-color: var(--rd-border-hover);
      box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    }

    header {
      position: inherit;
      z-index: inherit;
      border-bottom: 1px solid var(--rd-border);
      border-radius: 5px 5px 0 0;
      background-color: rgba(255, 255, 255, 0.02);
    }
    header h3 {
      display: flex;
      align-items: center;
      font-size: 1.25rem;
    }
    header h3 a {
      text-decoration: none;
      &:hover {
        text-decoration: underline;
        text-underline-offset: 0.2em;
      }
    }
    header i {
      padding-right: 1rem;
    }
    &:nth-child(1) header i { color: rgb(1, 170, 255); }
    &:nth-child(2) header i { color: #f96746; }
    &:nth-child(3) header i { color: #18a902; }
    &:nth-child(4) header i { color: #D700AB; }
    &:nth-child(5) header i { color: #d63535; }
    &:nth-child(6) header i { color: #eeae37; }

    header mark {
      margin-left: auto;
      border-radius: 999px;
      font-size: 0.75rem;
      font-weight: 600;
      letter-spacing: 0.03em;
      text-transform: uppercase;
      border-bottom: none;
      padding: 0.2rem 0.6rem;
    }

    .content {
      flex: 1;
      p:last-child {
        margin-bottom: 0;
      }
    }

    .content i {
      display: block;
      font-size: 4rem;
      color: var(--pico-primary-background);
      text-align: center;
      padding: 0.5rem 0 1rem 0;
    }
    .content.mid {
      justify-content: center;
      height: 100%;
      display: flex;
      flex-direction: column;
    }
  }
}


/* components/contributors.css */
#content:has(#contributors) {
  @media (min-width: 1024px) {
    padding-right: 220px;
  }
  @media (min-width: 1280px) {
    padding-right: 270px;
  }
}

#contributors {
  overflow: hidden;
  padding: 1rem;
  font-size: 0.9rem;
  border: 1px solid var(--rd-border);
  border-radius: 5px;
  margin-top: 1rem;
  background-color: var(--rd-surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);

  /* Matches the card header in cards.css. */
  header {
    border-bottom: 1px solid var(--rd-border);
    border-radius: 5px 5px 0 0;
    background-color: rgba(255, 255, 255, 0.02);
  }

  @media (max-width: 1023px) {
    /* Place below content on mobile. */
    order: 1;
    margin-top: 2rem;
  }
  @media (min-width: 1024px) {
    position: absolute;
    right: 0;
    width: 200px;
  }
  @media (min-width: 1280px) {
    width: 250px;
    display: block;
  }

  h2 {
    font-size: 1.25rem;
  }

  ul {
    padding-left: 0;
    li {
      list-style: none;
      display: flex;
      align-items: center;
      margin-bottom: 1rem;
      .icon {
        width: 50px;
        border-radius: 25px;
        margin-right: 1rem;
      }
    }
  }

  footer {
    text-align: center;
  }
}


/* components/docs.css */
/* Docs pages: sidebar and content columns. */
.section-pages main {
  margin-top: 50px;

  @media (min-width: 768px) {
    display: grid;
    grid-template-columns: 14rem minmax(0, 1fr);
    gap: 2rem;
    align-items: start;
  }
}

main #content {
  overflow: auto;
  display: flex;
  flex-direction: column;
}



/* components/footer.css */
body > footer {
  margin-top: 4rem;
  padding: 2rem 0;
  border-top: 1px solid var(--rd-border);
  background-color: rgba(0, 0, 0, 0.25);

  ul {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem 2rem;
    margin: 0;
    padding: 0;
    li {
      list-style: none;
      margin: 0;
      padding: 0;
    }
    a {
      color: var(--rd-muted);
      text-decoration: none;
      transition: color 0.15s;
      &:hover {
        color: #fff;
      }
    }
  }
}


/* components/header.css */
body > header {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 0;
  background-color: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);

  .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--rd-header-height);
    padding: 0 1rem;
  }

  a#logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: -0.01em;
    color: white;
  }

  #main-menu {
    ul {
      gap: 0.25rem;
    }
    li {
      padding: 0;
      a {
        display: flex;
        align-items: center;
        margin: 0;
        padding: 0.4rem 0.75rem;
        border-radius: 6px;
        color: #c9ced8;
        text-decoration: none;
        transition: color 0.15s, background-color 0.15s;

        &:hover {
          color: #fff;
          background-color: rgba(255, 255, 255, 0.07);
        }
        @media (max-width: 480px) {
          padding: 0.4rem 0.5rem;
          i {
            margin-right: 0.35rem;
          }
        }
      }
    }
  }
}


/* components/home.css */
#raindeer {
  display: block;
  max-width: 350px;
  margin: 0 auto;
  padding-bottom: 1rem;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.45));
}

#overview {
  padding-bottom: 3rem;

  p strong {
    display: inline-block;
    margin-top: 0.5rem;
    font-size: 1.4rem;
  }

  .actions {
    display: block;
    margin-top: 1.5rem;
  }
  p {
    font-size: 1.25rem;
    text-align: center;
    max-width: 800px;
    display: block;
    margin: 0 auto;
  }
  ul#releases {
    margin: 1rem 0 0 0;
    padding-left: 0;
    text-align: center;
    a {
      color: #aaa;
      text-decoration: none;
      &:hover {
        color: #fff;
      }
    }
    li {
      color: #aaa;
      font-size: 0.75rem;
      display: inline-block;
      list-style: none;
    }
    li + li::before {
      content: ' | ';
    }
  }
}

.teaser {
  display: flex;
  flex-direction: column;
  align-items: center;
  @media (min-width: 768px) {
    flex-direction: row;
  }
  margin: 4rem auto;
  max-width: 860px;
  padding: 1rem;
  border: 1px solid var(--rd-border);
  border-radius: 16px;
  background:
    radial-gradient(circle at 0% 50%, rgba(1, 114, 173, 0.15), transparent 60%),
    var(--rd-surface);
  img {
    padding: 1rem;
    max-width: 300px;
  }
  .content {
    padding: 1rem;
    h2 {
      font-size: 1.3rem;
    }
    p {
      font-size: 1.25rem;
      &:last-child {
        margin-bottom: 0;
      }
    }
  }
}

#diff {
  --diff-del: rgba(248, 81, 73, 0.12);
  --diff-del-text: #ffa198;
  --diff-add: rgba(46, 160, 67, 0.15);
  --diff-add-text: #7ee787;

  max-width: 860px;
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid var(--rd-border);
  border-radius: 5px;
  background-color: var(--rd-surface);
  font-family: 'DM Mono', monospace;
  font-size: 0.9rem;
  line-height: 1.9;

  .diff-header,
  .diff-row {
    display: grid;
    @media (min-width: 768px) {
      grid-template-columns: 1fr 1fr;
    }
    > div {
      display: flex;
      align-items: center;
      padding-right: 1rem;
      @media (min-width: 768px) {
        & + div {
          border-left: 1px solid var(--rd-border);
        }
      }
    }
  }

  .diff-header {
    /* Both sides stay labelled, even in the unified mobile view. */
    grid-template-columns: 1fr 1fr;
    border-bottom: 1px solid var(--rd-border);
    background-color: rgba(255, 255, 255, 0.03);
    > div {
      padding: 0.4rem 1rem;
      color: var(--rd-muted);
      & + div {
        border-left: 1px solid var(--rd-border);
      }
    }
    .count {
      margin-left: auto;
    }
    .del .count { color: var(--diff-del-text); }
    .add .count { color: var(--diff-add-text); }
  }

  .num {
    flex: none;
    width: 3rem;
    padding-right: 0.75rem;
    text-align: right;
    color: var(--rd-muted);
    opacity: 0.6;
    user-select: none;
  }
  .sign {
    flex: none;
    width: 1.5rem;
    user-select: none;
  }

  .diff-row {
    .del {
      background-color: var(--diff-del);
      color: var(--diff-del-text);
    }
    .add {
      background-color: var(--diff-add);
      color: var(--diff-add-text);
    }
    .empty {
      background-color: rgba(0, 0, 0, 0.2);
      @media (max-width: 767px) {
        display: none;
      }
    }
  }
}


/* components/status.css */
.status-404 {
  margin: 2rem 0 4rem;
  text-align: center;

  .actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
  }
}


/* components/typography.css */
h1 {
  margin-bottom: calc(var(--pico-typography-spacing-vertical) * 2);
  letter-spacing: -0.02em;
}

h2 {
  letter-spacing: -0.01em;
}

#content {
  > h2 {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--rd-border);
  }
  a:not([role="button"]) {
    text-underline-offset: 0.2em;
  }
}

article header {
  h2,
  h3 {
    margin-bottom: 0;
  }
}

img + *,
.markdown-alert + * {
  margin-top: 1rem;
}

button,
a[role=button] {
  border: 4px solid #a7a5bd;
  border-radius: 10px;
}

button i,
a i {
  margin-right: 0.5rem;
  vertical-align: middle;
}


/* components/sidebar/sidebar.css */
aside#sidebar {
  padding: 1rem;
  padding-left: 0;

  @media (min-width: 768px) {
    position: sticky;
    top: calc(var(--rd-header-height) + 1rem);
    max-height: calc(100vh - var(--rd-header-height) - 2rem);
    overflow-y: auto;
    scrollbar-width: thin;
  }

  nav {
    ul:first-of-type {
      margin-left: 0; /* Override Pico. */
    }
    li {
      padding: calc(var(--pico-nav-element-spacing-vertical) * .25) var(--pico-nav-element-spacing-horizontal);
      padding-left: calc(var(--pico-nav-element-spacing-vertical) * 1);
      border-left: 1px solid var(--rd-border);
      transition: border-color 0.15s;
      a {
        color: #c9ced8;
        text-decoration: none;
        &:hover {
          color: var(--pico-primary);
        }
      }
      &:has(a.active) {
        border-left: 2px solid var(--pico-primary);
        a {
          color: #fff;
          font-weight: 600;
        }
      }
    }
  }
  summary {
    list-style-type: none;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: bold;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--rd-muted);
  }
}


/* components/toc/toc.css */
#content:has(#toc) {
  @media (min-width: 1024px) {
    padding-right: 220px;
  }
  @media (min-width: 1280px) {
    padding-right: 270px;
  }
}

@media (min-width: 1024px) {
  .floating {
    position: absolute;
    top: 1rem;
    right: 0;

    @media (min-width: 1024px) {
      width: 200px;
    }
    @media (min-width: 1280px) {
      width: 250px;
    }
    #toc {
      position: fixed;
      width: inherit;
      /* Header + main's top margin and padding + this offset, plus a gap below. */
      max-height: calc(100vh - var(--rd-header-height) - 50px - 3rem);
      overflow-y: auto;
      scrollbar-width: thin;
    }
  }
}

details#toc {
  display: inline-block;
  padding: 1rem;
  font-size: 0.9rem;
  border: 1px solid var(--rd-border);
  border-radius: 10px;

  @media (min-width: 1024px) {
    display: block;
    border-width: 0;
    border-left: 1px solid var(--rd-border);
    border-radius: 0;
  }

  /* Matches the sidebar nav headings. */
  summary {
    font-size: 0.8rem;
    font-weight: bold;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--rd-muted);

    @media (min-width: 1024px) {
      pointer-events: none;
      &::after {
        display: none;
      }
    }
  }
  ul {
    padding-left: 0;
    li {
      list-style: none;

      &.h3 { margin-left: 10px; }
      &.h4 { margin-left: 20px; }
      &.h5 { margin-left: 30px; }
      &.h6 { margin-left: 40px; }

      a {
        text-decoration: none;
        &.active {
          color: white;
          font-weight: bold;
          transition: color 0.5s ease-in-out 0;
          transition: font-weight 0.5s ease-in-out 0;
        }
      }
    }
  }
}

