:root {
  --bg: #afb7cf;
  --text: #262626;
  --icon-color: #f5c542;      /* yellow sun */
  --icon-url: url('files/icon-light.svg');   /* sun */
  --arrow-url: url('files/arrow-light.svg');
  --space: 1.5rem;
}

[data-theme="dark"] {
  --bg: #303850;
  --text: #d9d9d9;
  --icon-color: #d9d9d9;      /* or a cooler pale tone if you want the moon distinct from body text */
  --icon-url: url('files/icon-dark.svg');   /* moon */
  --arrow-url: url('files/arrow-dark.svg');
}

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

body {
  max-width: 75ch;
  margin: 0 auto;
  padding: 20px;
  box-sizing: border-box;
  color: var(--text);
  font-family: "Nunito", Arial, sans-serif;
  font-size: 1.25rem;
  line-height: 1.6;
}

pre {
 margin: 0;
 white-space: pre-wrap;   
 word-break: break-word;  
 box-sizing: border-box;  
 overflow-x: hidden;        
 max-width: 100%;
 font-family: "Nunito", Arial, sans-serif;
 font-size: 1.25rem;
 line-height: 1.6;
}

/* Theme */

#theme-toggle {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  line-height: 0;
}

.icon {
  display: inline-block;
  width: 50px;
  height: 50px;
  background-color: var(--icon-color);
  -webkit-mask: var(--icon-url) no-repeat center / contain;
          mask: var(--icon-url) no-repeat center / contain;
}

/* Typography */

h1, h3, a {
  font-weight: 700;
  color: var(--text);
}

h1 { font-size: 2.25rem; margin: 0; }
h3 { font-size: 1.75rem; margin: 0 0 0.5rem; }

a { text-decoration: none; }
a:hover { text-decoration: underline; }

/* Paragraphs: no outer margins, spacing only between paragraphs */
p {
  margin: 0;
  text-align: justify;
  overflow-wrap: break-word;
}

p + p { margin-top: 1em; }

/* Spacing: top margin only, all driven by --space */
h1, h2, h3, .cards, .cards-two, nav, hr, pre {
  margin-top: var(--space);
}

/* Header */

.header {
  margin-top: 2rem;
  padding-bottom: 1rem;
}

.header hr {
  margin: 0; /* hr + p above supplies the gap below the line */
}

/* Footer */

.footer {
  margin-top: 2rem;
  padding-bottom: 1rem;
}

.footer hr {
  margin: 0; /* hr + p above supplies the gap below the line */
}

/* Title */

.title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 1rem;
}

/* Nav */

nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 20px;
  font-size: 1.45rem;
}

/* Divider */

hr {
  border: none;
  height: 5.0px;
  background-color: var(--text);
  border-radius: 999px;
  margin-bottom: 0;
}

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

/* Copyright block (use <div class="copyright">) */

.copyright {
  margin-top: 2rem;
  padding-bottom: 1rem;
}

.copyright hr {
  margin: 0; /* hr + p above supplies the gap below the line */
}

.copyright p {
 margin-top: 1.5em;
}

/* Cards */

.cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem 2rem;
}

@media (min-width: 500px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 758px) {
  body, pre { font-size: 1.45rem; }
  h1 { font-size: 2.75rem; }
  h3 { font-size: 2.25rem; }
  .cards { grid-template-columns: repeat(3, 1fr); }
}

.cards > * { margin-top: 0; }

/* Cards, two-column variation */

.cards-two {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem 2rem;
}

@media (min-width: 500px) {
  .cards-two { grid-template-columns: repeat(2, 1fr); }
}

.cards-two > * { margin-top: 0; }

/*Back to Top*/

#backToTop {
  display: none;
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 99;
  width: 50px;
  height: 50px;
  cursor: pointer;
  border: none;
  background-color: transparent;
}

#backToTop::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: 50%; /* optional, if you want a circle behind it */
  background-color: var(--bg-accent, var(--bg));
}

#backToTop::after {
  content: "";
  position: absolute;
  inset: 0;
  background-color: var(--text);
-webkit-mask: var(--arrow-url) no-repeat center / contain;
          mask: var(--arrow-url) no-repeat center / contain;
}