@import url('open-props.min.css');
@import url('reset.css');
@import url('fonts.css');
@import url('prism.css');
@import url('prism-dracula.css');
@import url('spacing.css');

/* ANCHOR Config
------------------------------------------------------------- */

:root {
  color-scheme: light;
  --_text-color: #1c1b19;
  --_darker-text-color: #111110;
  --_bg: #fff;
  --_accent: var(--red-8);
  --_border: #c6c6c6;
  --_main-menu-bg: #eee;
  --_bg-alt: var(--brown-0);
  --_red-text: var(--red-11);
  --_button-bg: var(--_accent);
  --_button-outline: var(--red-2);
  --_button-text: var(--_bg);

  --_text: 'Valkyrie B', 'Iowan Old Style', 'Georgia', Apple Garamond,
    Baskerville, Times New Roman, Droid Serif, Times, Source Serif Pro, serif,
    Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;
  --_headings: 'Heliotrope 3', -apple-system, BlinkMacSystemFont, avenir next,
    avenir, segoe ui, helvetica neue, helvetica, Cantarell, Ubuntu, roboto, noto,
    arial, sans-serif;
  --_code: 'Input Sans Reg', monospace;

  --_li-spacing: 0.25em;
}

/* Dark color scheme (Forced) */
/* Enabled if forced with data-theme="dark" */
[data-theme='dark'] {
  color-scheme: dark;
  --_text-color: #fff8f0;
  --_darker-text-color: #f9c8ce;
  --_bg: var(--gray-9); /* bg */
  --_bg-alt: #283331;
  --_accent: #f7708e;
  --_border: var(--gray-7);
  --_red-text: #f9c8ce;
  --_button-bg: var(--red-9);
  --_button-text: #fff;
}

[data-theme='light'] {
  --shadow-color: 220 3% 15% !important;
  --shadow-strength: 1% !important;
  --inner-shadow-highlight: inset 0 -0.5px 0 0 #fff, inset 0 0.5px 0 0 #0001 !important;
}

[data-theme='dark'] {
  --shadow-color: 220 40% 2% !important;
  --shadow-strength: 25% !important;
  --inner-shadow-highlight: inset 0 -0.5px 0 0 #fff1, inset 0 0.5px 0 0 #0007 !important;
}

/* ANCHOR Accessibility
------------------------------------------------------------- */

.sr-only,
.assistive-text {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
.sr-only-focusable:active,
.sr-only-focusable:focus {
  position: static;
  width: auto;
  height: auto;
  margin: 0;
  overflow: visible;
  clip: auto;
}

/* Hide elements with the `hidden` attribute */
[hidden] {
  display: none;
}

.skip-link {
  position: absolute;
  top: 0;
  left: 0;
  display: inline-block;
  opacity: 0;
  pointer-events: none;
}

.skip-link:focus {
  opacity: 1;
  pointer-events: auto;
}

/* ANCHOR Global styles
------------------------------------------------------------- */

html {
  background-color: var(--_bg);
}

body {
  display: flex;
  flex-direction: column;
  max-width: unset;
  min-height: 100vh;
  padding: unset;
  -webkit-font-smoothing: subpixel-antialiased;

  [data-theme='dark'] & {
    -webkit-font-smoothing: antialiased;
  }
}

.container {
  max-width: 800px;
  margin-inline: auto;
  padding-inline: 1em;
}

a {
  color: var(--_text-color);
  text-decoration-color: var(--_accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.1em;
  transition:
    color 0.15s var(--ease-1),
    text-decoration-color 0.15s var(--ease-1);

  &:hover,
  &:focus-visible {
    color: var(--_accent);
    text-decoration-color: var(--_accent);
  }
}

[data-theme='dark'] {
  a {
    &:hover,
    &:focus-visible {
      color: var(--_red-text);
    }
  }
}

main details {
  border: 1px solid transparent;
  border-radius: 0.5em;
  overflow: hidden;

  &:hover,
  &:focus {
    border: 1px solid var(--_border);
  }

  &[open] {
    border: 1px solid var(--_border);
  }

  /* the last thing in the details element should have 0 margin-bottom
     the language thing is to increase specificity for code blocks */
  > &:last-child,
  > [class*='language-']:last-child {
    margin-block-end: 0;
  }
}

main summary {
  padding: 0.5em;
  cursor: pointer;

  &::marker {
    color: var(--_accent);
  }

  /* the first thing after the summary element should have 0.5em margin-top
     the language thing is to increase specificity for code blocks */
  & + *,
  & + [class*='language-'] {
    margin-block-start: 0.5em;
  }
}

video,
iframe {
  margin-block: 1.75em;
  max-width: 100%;
}

main img {
  margin-block: 1.75em;
  margin-inline: auto;
  max-width: 100%;
}

@media (min-width: 700px) {
  .container {
    padding-inline: 1.5em;
  }
}

/* Dark color scheme (Forced) */
/* Enabled if forced with data-theme="dark" */
[data-theme='dark'] {
  & img {
    opacity: 0.85;
    transition: opacity 150ms linear;
  }

  & img:hover {
    opacity: 1;
  }
}

/* ANCHOR Header
------------------------------------------------------------- */

.site-header {
  margin-block-end: var(--size-9);
}

.logo-wrap {
  margin-block-end: var(--size-5);
  padding-block: var(--size-4);
}

.site-title {
  & a {
    display: inline-block;
    text-decoration: none;
  }

  & a:hover #mascot {
    opacity: 0;
  }

  & a:hover #mascot-hover {
    opacity: 1;
  }

  & img,
  & svg {
    max-width: 350px;
    width: 100%;
    height: auto;
    opacity: 1;
  }
}

@media (min-width: 1100px) {
  .site-title {
    position: relative;
    transform: translateX(-112px);
  }
}

[data-theme='dark'] .hero {
  opacity: 0.8;
}

.main-menu {
  border: 1px solid var(--_border);
  border-radius: 0.5em;
  box-shadow: var(--shadow-2);

  &:hover,
  &:focus {
    border: 1px solid var(--gray-7);
  }

  &[open] {
    border: 1px solid var(--gray-7);
    padding-bottom: 1rem;
  }

  & [aria-current='page'] {
    text-decoration: none !important;
    color: var(--_accent);
  }
}

.main-menu nav {
  padding-inline: 0.75em;
}

.main-menu summary {
  padding: 0.5em;
  cursor: pointer;

  &::marker {
    color: var(--_accent);
  }
}

.main-menu ul {
  margin-block-start: 0.25em;
  margin-block-end: 0.25em;
  padding-inline-start: 0;
  padding-block-end: 0.5em;
  list-style-type: none;
}

.menu-heading {
  margin-top: var(--size-2);
}

/* Settings */

.settings {
  margin-inline: 0.75em;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 0.25em;
}

[data-theme='dark'] {
  .main-menu {
    &:hover,
    &:focus,
    &[open] {
      border: 1px solid var(--gray-6);
    }
  }
}

/* ANCHOR Typography
------------------------------------------------------------- */

:root {
  border-top: none; /* remove Neat border */
  font-family: var(--_text);
  color: var(--_text-color);
}

main > *,
.stack > * {
  margin-block: 0;
}

main > * + *,
.stack > * + * {
  margin-block-start: 1rem;
}

h1,
h2,
h3,
h4 {
  & a {
    text-decoration: none;
    color: var(--_text);

    &:hover,
    &:focus {
      text-decoration: underline;
    }
  }
}

h1 {
  margin-block-end: var(--size-7);
  font-size: var(--size-7);
}

h1,
h2 {
  font-family: var(--_headings);
  font-weight: normal;
  line-height: 1.2;
  text-wrap: pretty;
}

h2 {
  margin-block-start: 1.75em;
  margin-block-end: 1.5rem;
  font-size: var(--size-5);
}

h3 {
  margin-block-start: 1.5em;
  font-size: 1.1rem;
}

ul,
ol {
  margin-block-start: var(--size-3);
  padding-inline-start: 1.75em;
}

ul ul,
ul ol,
ol ul,
ol ol {
  margin-block-start: 0;
}

li {
  margin-block-start: var(--_li-spacing);
}

li::marker {
  color: var(--_accent);
}

code {
  display: inline-block;
  font-family: var(--_code) !important;
  font-size: 0.85em;
  line-height: 1.5;
  color: var(--_red-text);

  &:not(pre &) {
    padding: 0 0.25em;
    border-radius: 0.25em;
    background-color: var(--red-0);
  }
}

pre code {
  background-color: transparent;
  color: inherit;
}

pre[class*='language-'] > code {
  display: block;
  padding: 0;
  font-size: 0.75em;
}

pre,
pre[class*='language-'] {
  margin-block: 1.75em;
  padding: 1rem;
  border: 1px solid var(--_border);
  border-radius: 0.25em;
  max-height: 600px;
  box-shadow: var(--shadow-3);
  color: #1c1b19;
  scrollbar-color: var(--_border) transparent;
  overflow: auto;
}

details pre,
details pre[class*='language-'] {
  border: none;
  border-radius: 0;
}

.token {
  color: unset;
}

.wrap-code code[class*='language-'],
.wrap-code [class*='language-'] {
  white-space: pre-wrap;
  /* word-break: break-word; */
}

/* font style utility classes */
.sans-serif {
  font-family:
    -apple-system,
    BlinkMacSystemFont,
    avenir next,
    avenir,
    segoe ui,
    helvetica neue,
    helvetica,
    Cantarell,
    Ubuntu,
    roboto,
    noto,
    arial,
    sans-serif !important;
}

.serif {
  font-family: var(--_text) !important;
}

.mono {
  font-family:
    Menlo,
    Consolas,
    Monaco,
    Liberation Mono,
    Lucida Console,
    monospace !important;
  font-size: 0.8rem;
}

@media (min-width: 700px) {
  :root {
    font-size: 1.25em;
  }

  pre,
  pre[class*='language-'] {
    margin-inline: -1em;

    details & {
      margin-inline: auto;
    }
  }
}

/* Dark color scheme (Forced) */
/* Enabled if forced with data-theme="dark" */
[data-theme='dark'] pre:not([class*='language-']) {
  background-color: var(--gray-11);
  border-color: var(--gray-8);
}

[data-theme='dark'] pre,
[data-theme='dark'] pre[class*='language-'] {
  color: var(--_red-text);
}

[data-theme='dark'] code:not([class*='language-']) {
  color: var(--_red-text);
  background-color: var(--gray-11);
}

[data-theme='dark'] mark {
  background-color: #90d8ff40;
  color: var(--_text-color);
}

/* ANCHOR Components
------------------------------------------------------------- */

aside {
  position: relative;
  margin-block: var(--size-6);
  margin-inline-start: var(--size-6);
  padding: var(--size-5);
  padding-inline-start: var(--size-7);
  border: var(--border-size-2) solid var(--red-4);
  border-radius: var(--radius-drawn-3);
  font-size: 0.85em;
  line-height: 1.45;
  background-color: var(--red-0);
  box-shadow: var(--shadow-3);

  /* border variations */
  &:nth-of-type(2) {
    border-radius: var(--radius-drawn-4);
  }
  &:nth-of-type(3) {
    border-radius: var(--radius-drawn-5);
  }
  &:nth-of-type(4) {
    border-radius: var(--radius-drawn-6);
  }
  &:nth-of-type(5) {
    border-radius: var(--radius-drawn-1);
  }
  &:nth-of-type(6) {
    border-radius: var(--radius-drawn-2);
  }

  * {
    margin: 0;
  }

  & p {
    orphans: 2;
  }

  > * + * {
    margin-block-start: 1rem;
  }

  & li {
    margin-block-start: var(--_li-spacing);
  }

  & pre,
  & pre[class*='language-'] {
    margin-block: 1rem 0;
    margin-inline: 0;
  }

  /* mascot */
  --mascot-multiple: 7;

  &:before {
    content: ' ';
    position: absolute;
    top: calc(120px / var(--mascot-multiple));
    left: calc(-310px / var(--mascot-multiple));
    height: calc(291px / var(--mascot-multiple));
    width: calc(464px / var(--mascot-multiple));
    background-image: url('../img/design/mascot-aside-back.svg');
    background-position: center;
    background-size: contain;
    background-repeat: no-repeat;
    z-index: -1;
  }

  &:after {
    content: ' ';
    position: absolute;
    top: calc(-8px / var(--mascot-multiple));
    left: calc(-30px / var(--mascot-multiple));
    height: calc(535px / var(--mascot-multiple));
    width: calc(156px / var(--mascot-multiple));
    background-image: url('../img/design/mascot-aside-front.svg');
    background-position: center;
    background-size: contain;
    background-repeat: no-repeat;
    z-index: 1;
  }
}

[data-theme='light'] aside code:not(pre code) {
  background-color: #00000011;
}

.aside-label {
  font-family: var(--_text);
  font-weight: bold;
  font-size: 0.85em;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.085em;
  color: var(--_text-color);

  & + * {
    margin-block-start: 0.5rem;
  }
}

@media (min-width: 900px) {
  aside {
    --mascot-multiple: 5;
    margin-inline: 0;
  }
}

[data-theme='dark'] aside {
  border-color: var(--gray-6);
  background-color: var(--gray-8);
}
[data-theme='dark'] aside code:not(pre code) {
  background-color: #f7708e33;
}

/* ---------------------------------------------------------- */

figure {
  margin-inline: 0;

  & img {
    display: block;
    margin-inline: auto;
    max-width: 100%;
  }
}

figcaption {
  margin-block-start: 0.5rem;
  font-size: 0.85em;
}

/* ---------------------------------------------------------- */

elevator-button a {
  display: flex;
  align-items: center;
  justify-content: center;
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  box-shadow: 0 0 0.5rem 0.25rem #00000011;
  font-size: 1.5rem;
  font-weight: bold;
  background-color: var(--_text-color);
  color: var(--_bg);
  text-decoration: none;
  opacity: 0;
  transition: opacity 0.2s linear;
  pointer-events: none;

  &.active {
    opacity: 1;
    pointer-events: auto;
  }

  &:before {
    content: '↑';
    color: var(--_bg);
  }
}

.elevator-arrow {
  color: var(--_bg);
}

/* ---------------------------------------------------------- */

.chapter-nav {
  display: flex;
  justify-content: space-between;
  flex-direction: column;
  margin-block: 1.5rem 0;
  border-top: 1px solid var(--_border);
  text-align: center;

  & a {
    padding: 1em 1em;
    width: 100%;
    transition:
      background-color 0.1s var(--ease-1),
      color 0.1s var(--ease-1),
      text-decoration-color 0.1s var(--ease-1);

    &:hover,
    &:focus {
      text-decoration-color: var(--_red-text);
      background-color: var(--red-0);
      color: var(--_red-text);
    }

    &:has(+ a) {
      border-block-start: 1px solid var(--_border);
    }
  }
}

[data-theme='dark'] {
  .chapter-nav a {
    &:hover,
    &:focus {
      text-decoration-color: var(--_accent);
      background-color: var(--gray-10);
    }
  }
}

@media (min-width: 700px) {
  .chapter-nav {
    margin-block-start: 3rem;
    flex-direction: row;

    & a:first-child {
      order: 1;
    }

    & a:has(+ a) {
      border-block-start: none;
      border-inline-start: 1px solid var(--_border);
    }
  }
}

/* ANCHOR Forms
------------------------------------------------------------- */

/* buttons */
button,
a.button {
  display: inline-block;
  position: relative;
  padding: 0.5em 1em;
  border-radius: var(--radius-2);
  box-shadow: var(--shadow-3);
  text-decoration: none;
  background-color: var(--_button-bg);
  color: var(--_button-text);
  outline: 0 solid var(--red-2);
  transition: outline-width 0.2s var(--ease-1);
  text-align: center;

  &:hover,
  &:focus-visible {
    color: #fff;
    outline: 8px solid var(--red-2);
  }
}

form button[type='submit'] {
  display: inline-block;
  width: unset;
}

[data-theme='dark'] {
  & button,
  & a.button {
    outline-color: var(--gray-7);
  }
}

/* ANCHOR Promo
------------------------------------------------------------- */

.promo {
  padding-block: 3rem;
  border-block-start: 1px solid #e0cab1;
  background-color: var(--_bg-alt);

  & + .site-footer {
    margin-block-start: 0;
    padding-block-start: 1rem;
  }
}

.promo-title {
  margin-block-end: var(--size-7);
  font-size: 1.125rem;
  font-weight: bold;
}

/* Dark color scheme (Forced) */
/* Enabled if forced with data-theme="dark" */
[data-theme='dark'] {
  .promo {
    border-block-start: 1px solid #3e5d59;
    background-color: #283331;
    color: #fff8f0;
  }
}

/* ANCHOR Home
------------------------------------------------------------- */

.hero {
  margin-inline: auto;

  max-width: 1400px;
  & svg {
    max-width: 100%;
  }
}

g#rocket,
g#donut-before,
g#donut-after,
g#coffee-before,
g#coffee-after {
  &:hover {
    cursor: pointer;
  }
}

#cloud {
  pointer-events: none;
}

.home-buttons {
  display: flex;
  flex-wrap: wrap;

  & a {
    display: block;
    margin-block-end: 0.5rem;
    width: 100%;
  }
}

@media (min-width: 500px) {
  .home-buttons {
    flex-wrap: nowrap;

    & a {
      margin-inline-end: 1rem;
      width: auto;
    }
  }
}

/* ANCHOR Footer
------------------------------------------------------------- */

.site-footer {
  margin-block-start: 3rem;
  padding-block: 2rem;
  /* border-block-start: 1px solid var(--border); */
  font-size: 0.85em;
  background-color: var(--_bg-alt);
}
