/* Fonts */
@font-face {
  font-family: 'Alegreya';
  src: url('fonts/Alegreya-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Alegreya';
  src: url('fonts/Alegreya-Italic.woff2') format('woff2');
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: 'Jost';
  src: url('fonts/Jost-VariableFont.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* Reset & base */
*, *::before, *::after { box-sizing: border-box; }

html {
  color-scheme: light;
  scrollbar-width: thin;
}

body {
  font-family: 'Alegreya', serif;
  font-size: 20px;
  line-height: 1.65;
  color: #3a3a3a;
  background-color: #f4f4f4;
  background-image: url('../images/texture.png');
  overflow-wrap: break-word;
  text-rendering: optimizeLegibility;
  margin: 0;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-family: 'Jost', sans-serif;
  font-weight: 250;
  color: #1f1f1f;
  letter-spacing: 0em;
  line-height: 1.3;
  margin-top: 1.5em;
  margin-bottom: 0.35em;
  padding-bottom: 0.3em;
  border-bottom: 1px solid #ccc;
}

h1 { font-size: 2.7rem; margin-top: 0.25em; }
h2 { font-size: 2.2rem; }
h3 { font-size: 1.8rem; }
h4 { font-size: 1.5rem; }
h5, h6 { font-size: 1.2rem; }

p { margin: 0 0 1em; }

strong, b { font-weight: 400; }

em { font-style: italic; }

small { font-size: 0.85em; }

/* Links */
a { color: #1B75A6; text-decoration: none; }
a:hover { color: #3B95C6; }
a:focus { outline: 2px solid #1B75A6; outline-offset: 2px; }

/* Code */
code, kbd, samp {
  font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', Menlo, Consolas, monospace;
  background: #e8e8e8;
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 0.95em;
}

kbd { border: 1px solid #ccc; }

pre {
  margin: 1em 0;
  overflow-x: auto;
}

pre > code {
  display: block;
  padding: 1em;
  overflow-x: auto;
  background: #e8e8e8;
  border-radius: 4px;
}

/* Tables */
table {
  border-collapse: collapse;
  width: 100%;
  margin-bottom: 1em;
  font-size: 0.95em;
}

th, td {
  padding: 6px 10px;
  text-align: left;
  vertical-align: top;
}

thead { border-bottom: 1px solid #ccc; }
th { font-family: 'Jost', sans-serif; font-weight: 450; }

tbody tr:nth-child(even) { background: #efefef; }

/* Misc elements */
hr {
  border: none;
  border-top: 1px solid #ccc;
  margin: 2em 0;
}

img, video {
  max-width: 100%;
  height: auto;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

p:has(> img) + p > em:only-child {
  display: block;
  text-align: center;
}

ul, ol { padding-left: 1.5em; margin: 0 0 1em; }
li { margin-bottom: 0.25em; }

.footnotes { font-size: 0.9em; }
.footnotes ol { padding-left: 1.4em; }
.footnotes li { margin-bottom: 0.3em; }
.footnotes li p { margin-bottom: 0.25em; }

.chapter-list {
  list-style: none;
  padding-left: 0;
  counter-reset: chapter;
}

.chapter-list li {
  display: flex;
  align-items: center;
  gap: 2rem;
  margin-bottom: 2rem;
  counter-increment: chapter;
}

.chapter-list li::before {
  content: counter(chapter, decimal-leading-zero);
  font-family: 'Jost', sans-serif;
  font-weight: 100;
  font-size: 3.5rem;
  line-height: 1;
  color: #1f1f1f;
  flex-shrink: 0;
  min-width: 3rem;
  text-align: right;
}

.chapter-content a {
  display: block;
  font-family: 'Jost', sans-serif;
  font-size: 1.5em;
  font-weight: 250;
}

.chapter-content small {
  display: block;
  font-size: 1.2rem;
  margin-top: 0.1rem;
}

/* Layout */
.container {
  display: flex;
  min-height: 100vh;
}

aside {
  width: 275px;
  min-width: 275px;
  padding: 2rem 1.5rem;
  background: url('../images/grey.jpg') repeat fixed;
  /* background: linear-gradient(to bottom, #191c1f, #282e30); */
  font-family: 'Jost', sans-serif;
  position: sticky;
  top: 0;
  height: 100vh;
  align-self: flex-start;
  overflow-y: auto;
}

/* Placeholder for trying a texture over a linear gradient
aside::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url('../images/canvas.jpg') repeat;
  opacity: 0.25;
  pointer-events: none;
} */

aside a,
aside strong {
  color: #dedede;
  display: block;
  text-decoration: none;
}

aside strong {
  font-size: 1.6em;
  font-weight: 250;
  font-variant: small-caps;
  letter-spacing: 0.08em;
}

aside .nav-section > a {
  font-size: 1.3em;
  font-weight: 225;
  display: block;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid #555;
}

aside a:hover { color: #fff; text-decoration: none; }
aside a:focus { outline: 2px solid #dedede; outline-offset: 2px; }

aside ul {
  list-style: none;
  padding: 0;
  margin: 0.25rem 0 0 1.75rem;
}

aside ul li a {
  font-size: 1.13em;
  font-weight: 225;
  padding: 0.55rem 0;
}

aside ul li a.active {
  text-shadow: 0 0 0.5px currentColor, 0 0 0.5px currentColor;
}

.nav-section { margin-top: 1.25rem; }

.nav-desktop { display: block; }

.nav-mobile { display: none; }

.nav-mobile summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  cursor: pointer;
  color: #dedede;
}

.nav-mobile summary::-webkit-details-marker { display: none; }

.nav-mobile summary::marker { content: ''; }

.nav-mobile summary:focus-visible {
  outline: 2px solid #dedede;
  outline-offset: 2px;
}

/* Mobile menu label */
.nav-mobile-label {
  flex: 1;
  font-size: 0.85em;
  font-weight: 250;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Mobile hamburger icon */
.nav-mobile-toggle {
  width: 1.15rem;
  height: 0.9rem;
  flex-shrink: 0;
  opacity: 0.92;
  background:
    linear-gradient(currentColor 0 0) center top / 100% 1.5px no-repeat,
    linear-gradient(currentColor 0 0) center center / 100% 1.5px no-repeat,
    linear-gradient(currentColor 0 0) center bottom / 100% 1.5px no-repeat;
  transition: transform 0.2s ease;
}

.nav-mobile[open] .nav-mobile-toggle { transform: rotate(90deg); }

.nav-mobile-panel {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid #555;
}

.nav-mobile-home {
  font-size: 1.3em;
  font-weight: 250;
  padding-bottom: 0.75rem;
  letter-spacing: 0.08em;
  font-variant: small-caps;
}

main {
  flex: 1;
  padding: 3rem 3rem 2rem 3rem;
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
}

/* Page navigation */
.page-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid #ccc;
  font-size: 1.01em;
}

.page-nav-next { margin-left: auto; }

/* Selection */
::selection { background: #c5dce8; color: #3a3a3a; }

/* Mobile */
@media (max-width: 768px) {
  .container { flex-direction: column; }

  aside {
    width: 100%;
    min-width: unset;
    height: auto;
    position: static;
    padding: 1rem;
  }

  .nav-desktop { display: none; }

  .nav-mobile { display: block; }

  .nav-mobile .nav-section { margin-top: 0.95rem; }

  .nav-mobile-panel .nav-section:first-of-type { margin-top: 0; }

  .nav-mobile .nav-section > a {
    font-size: 1.1em;
    padding-bottom: 0.35rem;
  }

  .nav-mobile ul { margin-left: 1.1rem; }

  .nav-mobile ul li a {
    font-size: 1em;
    padding: 0.45rem 0;
  }

  main { padding: 1rem; }
}
