:root {
  color-scheme: light;
  --text-color: black;
  --body-bg: white;
  --image-bg: #f0f0f0;
  --logo-bg: #eaeaea;
  --highlight-color: #dcdcdc;
  --selection-text: black;
  --hover-color: #d0d0d0;
  --toggle-color: #bdbdbd;
  --placeholder-opacity: 1;
  --grey-link: #888;

  /* fluid sizing shared by all pages: text and logo scale with the viewport,
     the same proportions on mobile and desktop, no jump at a breakpoint */
  --content-width: min(85vw, 70rem);
  --text-size: clamp(1.25rem, min(4vw, 1.1vw + 1.15rem), 2.5rem);
  --logo-width: clamp(10rem, min(40vw, 13vw + 8.7rem), 20.4rem);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --text-color: #c8c8c8;
  --body-bg: #282828;
  --image-bg: #333333;
  --highlight-color: #808080;
  --selection-text: #ffffff;
  --hover-color: #ffffff;
  --toggle-color: #c8c8c8;
  --placeholder-opacity: 0.12;
}

body {
  color: var(--text-color);
  transition: background-color 0.5s ease, color 0.5s ease;
}

::selection {
  background: var(--highlight-color);
  color: var(--selection-text);
}

#theme-toggle {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: 0;
  background: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* an eclipse: a cut-out disc of the same size slides across the circle, leaving a crescent.
   --p is 1 with the disc clear of the circle (light) and 0 with it in place (dark) */
@property --p {
  syntax: '<number>';
  inherits: false;
  initial-value: 1;
}

#theme-toggle::before {
  content: '';
  --cut-x: calc(0.38rem + var(--p) * 0.72rem);
  --cut-y: calc(-0.2rem - var(--p) * 0.38rem);
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  background: var(--toggle-color);
  -webkit-mask: radial-gradient(circle at calc(50% + var(--cut-x)) calc(50% + var(--cut-y)), transparent calc(0.55rem - 0.5px), #000 0.55rem);
  mask: radial-gradient(circle at calc(50% + var(--cut-x)) calc(50% + var(--cut-y)), transparent calc(0.55rem - 0.5px), #000 0.55rem);
  transition: --p 0.8s ease-in-out, background-color 0.3s ease;
}

:root[data-theme="dark"] #theme-toggle::before {
  --p: 0;
}

#theme-toggle:hover::before {
  background-color: var(--hover-color);
}
