/* Global fonts and colors */
html {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 16px;
  color: var(--text-color);
  background-color: var(--bg-color);
  --text-color: black;
  --bg-color: white;
  --code-color: #222222;
  --code-bg-color: #dedede;
  --heading-color: #007c41;
  --link-color: blue;
}

@media (prefers-color-scheme: dark) {
  html {
    --text-color: white;
    --bg-color: rgb(31, 31, 31);
    --code-color: #eee;
    --code-bg-color: #333333;
    --heading-color: rgb(0, 169, 87);
    --link-color: cyan;
  }
}

/* Header */
header {
  background: #007c41;
  border-bottom: 3px solid #ffdb05;
  width: 100%;
  display: flex;
  justify-content: center;
  margin-bottom: 1rem;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}

header img {
  max-height: 4rem;
}

/* Headings */
h1,
h2,
h3,
h4 {
  margin: 1rem 0 1rem 0;
  color: var(--heading-color);
  font-weight: normal;
}

h1 {
  font-weight: bold;
  font-size: 3rem;
}

h2 {
  font-weight: bold;
  font-size: 2rem;
}

h3 {
  font-size: 1.5rem;
  font-style: italic;
}

h4 {
  font-size: 1.25rem;
}

#creator {
  font-style: italic;
}

/* Content */
body {
  margin: 0;
}

main {
  max-width: 80ch;
  margin: auto;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

p,
li {
  line-height: 1.5;
}

a {
  color: var(--link-color);
}

pre {
  border: 1px solid gray;
  border-radius: 2px;
  padding: 1rem 0.5rem 1rem 0.5rem;
  overflow-x: auto;
}

pre,
code,
.mono {
  font-family: Consolas, 'Courier New', Courier, monospace;
}

pre,
code {
  color: var(--code-color);
  background-color: var(--code-bg-color);
  border-radius: 4px;
}

pre code {
  padding: 0;
  display: block;
}

code {
  white-space: pre;
  padding: 2px;
  counter-reset: line;
}

blockquote {
  margin-left: 0;
  padding-left: 12px;
  border-left: 6px solid #ccc;
}

/* Code with line count */
.code-line {
  counter-increment: line;
}

.code-line:before {
  content: counter(line);
  color: grey;
  width: 1em;
  margin-right: 1em;
  text-align: right;
  display: inline-block;
}

/* Images and videos */
main video,
main img {
  display: block;
  border-radius: 6px;
  max-width: 100%;
  margin-top: 1rem;
  margin-bottom: 1rem;
  box-shadow: rgba(134, 134, 160, 0.33) 0 0 12px 6px;
}

main img {
  text-align: center; /* center alt text in case image fails to load */
  margin-left: 0; /* left align images */
}

main img.centered {
  /* class for centered images */
  margin-left: auto;
  margin-right: auto;
}

main video {
  margin-left: auto; /* center videos */
  margin-right: auto;
}

/* Collapsible content */
.collapse-container {
  position: relative;
  margin-top: 1rem;
  margin-bottom: 1rem;
}

.toggle-checkbox {
  display: none; /* hide the checkbox */
}

.toggle-button {
  display: block;
  background-color: #007c41;
  color: white;
  padding: 0.5rem;
  cursor: pointer;
  text-align: center;
  border-radius: 4px;
  transition: background-color 0.3s;
  border: 1px solid gray;
}

.toggle-button:hover {
  background-color: #00592e;
}

.collapsible-content {
  max-height: 0;
  border-color: transparent;
  border-width: 1px;
  border-style: solid;
  border-radius: 4px;
  border-top-width: 0;
  transition: border-color 0.5s ease-out;
  margin: 0;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}

.toggle-checkbox:not(:checked) ~ .collapsible-content {
  padding-top: 0;
  padding-bottom: 0;
  overflow: hidden;
}

.toggle-checkbox:checked ~ .collapsible-content {
  border-color: gray;
  max-height: unset;
  overflow-y: hidden;
}

/* Note */
p.note {
  font-style: italic;
}

p.note::before {
  content: 'Note:';
  text-decoration: underline;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
}

th {
  color: var(--heading-color);
  font-size: 1.25rem;
}

th,
td {
  border: 1px solid var(--text-color);
  padding: 0.5rem;
}

/* 
Table representing a RISC-V word split into separate sections
First row of table is the bit numbers
Second row of table is the content of each part of the word
*/
table.split-word tr:first-child > td {
  border: none;
}

table.split-word tr:first-child > td:nth-child(even) {
  text-align: right;
}

table.split-word tr:last-child > td {
  text-align: center;
}
