:root {
  color-scheme: light dark;
  --text: light-dark(#000, #FFF);
  --bg: light-dark(#EEE, #242936);
  &:has([name="theme"][value="light"]:checked) {
    color-scheme: light;
  }
  &:has([name="theme"][value="dark"]:checked) {
    color-scheme: dark;
  }
}

html{
  padding: 1em;
  line-height: 1.75;
  font-size: 1.25em;
  color: var(--text);
  background-color: var(--bg);
  font-family: Verdana, Geneva, Tahoma, sans-serif;
}

body {
  padding-bottom: 50vh;
}

h1,h2,h3,h4,h5,h6 {
  margin: 2em 0 1em;
}

main {
  max-width: min(70ch, 100% - 4rem);
  margin-inline: auto;
}

p,ul,ol {
  margin-bottom: 2em;
}

li {
  margin-bottom: 0.5em;
}

input[type="text"],
input[type="email"],
input[type="password"],
input:not([type]),
textarea,
select {
  width: 100%;
  padding: 0.5em;
  font-size: 1em;
}

code {
  background: light-dark(#f4f4f4, #2b2b2b);
  padding: 0.2em 0.4em;
  border-radius: 3px;
  font-family: Consolas, "Courier New", monospace;
}

pre {
  background: light-dark(#f4f4f4, #2b2b2b);
  padding: 1em;
  width: 100%;
  overflow-x: auto;
  font-family: Consolas, "Courier New", monospace;
}

table {
  border-collapse: collapse;
  width: 100%;
  margin-bottom: 2em;
}

th, td {
  border: 1px solid light-dark(#ccc, #444);
  padding: 0.5em;
  text-align: left;
}

button,
input[type="submit"],
input[type="button"] {
  background-color: #007BFF;
  color: white;
  border: none;
  padding: 0.25em 0.5em;
  cursor: pointer;
  font-size: 1em;
  border-radius: 3px;
}

nav {
  margin-bottom: 2em;
  margin-top: 2em;
}

/* indent nested <dl> */
dl dl {
  margin-left: 2em;
  border-left: 5px solid light-dark(#ccc, #444);
  padding-left: 1em;
}

.highlight {
  color: salmon;
}

.mb-0 {
  margin: 0;
}

.pointer {
  cursor: pointer;
}

.block {
  display: block;
}

/* Theme Selector Styles */

#themeForm {
  position: absolute;
  top: 1em;
  right: 1em;
  background: light-dark(rgba(255,255,255,0.8), rgba(20,20,20,0.8));
  padding: 0.3em;
  border-radius: 5px;
  box-shadow: 0 0 10px light-dark(rgba(0,0,0,0.1), rgba(0,0,0,0.5));
  line-height: 1.5em;
}

#themeForm > label {
  font-size: 1.5em;
  transition: transform 0.2s ease;
}

#themeForm > label:hover {
  transform: scale(1.1);
}

/* Hide all labels by default */
#themeForm > label {
  display: none;
}

#themeForm input[type="radio"] {
  display: none;
}

/* Show only the next theme option based on current selection */
/* When light is checked, show dark */
#themeForm:has([value="light"]:checked) label:has([value="dark"]) {
  display: inline-block;
}

/* When dark is checked, show default */
#themeForm:has([value="dark"]:checked) label:has([value="default"]) {
  display: inline-block;
}

/* When default is checked (or nothing), show light */
#themeForm:has([value="default"]:checked) label:has([value="light"]),
#themeForm:not(:has([type="radio"]:checked)) label:has([value="light"]) {
  display: inline-block;
}

/* Nav */

@media (min-width: 1400px) {
  nav {
    display: flex;
    justify-content: flex-start;
    flex-direction: column;
    position: fixed;
    top: 1em;
    left: 1em;
    background: light-dark(rgba(255,255,255,0.8), rgba(20,20,20,0.8));
    padding: 0.5em 1em;
    border-radius: 5px;
    box-shadow: 0 0 10px light-dark(rgba(0,0,0,0.1), rgba(0,0,0,0.5));
    gap: 1em;

    span {
      display: none;
    }
  }
}
