:root {
  --bg: #fbfaf7;
  --text: #1f1d1a;
  --muted: #6b665e;
  --rule: #e4e0d8;
  --link: #1d5fa8;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161514;
    --text: #e8e5df;
    --muted: #9a958c;
    --rule: #2e2c29;
    --link: #8ab8ef;
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

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

main {
  max-width: 40rem;
  margin: 0 auto;
  padding: 3rem 1rem 4rem;
}

h1 {
  font-size: 1.75rem;
  line-height: 1.25;
  margin: 0 0 0.25rem;
}

h2 {
  font-size: 1.15rem;
  margin: 2rem 0 0.5rem;
}

.lede {
  color: var(--muted);
  margin-top: 0;
}

footer {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.9rem;
}

/* The root and 404 pages: one line, centred. */
.solo {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
  text-align: center;
}

.solo p {
  max-width: 32rem;
  margin: 0;
  font-family: Charter, "Bitstream Charter", "Iowan Old Style", "Sitka Text", Cambria, Georgia, serif;
  font-size: 1.375rem;
  line-height: 1.5;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

/* The punchline, after a beat. */
.solo .later {
  display: block;
  margin-top: 0.5em;
  opacity: 0;
  animation: arrive 0.9s ease-out 1.6s forwards;
}

/*
 * Name the device. CSS can't ask what it is, so guess from the input:
 * touch with no hover is a phone if its shorter side is under 600px, otherwise a tablet.
 * Anything else, including an iPad with a trackpad, is a computer.
 */
.on-tablet,
.on-phone {
  display: none;
}

@media (hover: none) and (pointer: coarse) {
  .on-computer {
    display: none;
  }

  .on-tablet {
    display: inline;
  }
}

@media (hover: none) and (pointer: coarse) and (max-width: 599px),
  (hover: none) and (pointer: coarse) and (max-height: 599px) {
  .on-tablet {
    display: none;
  }

  .on-phone {
    display: inline;
  }
}

@keyframes arrive {
  to {
    opacity: 1;
  }
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/*
 * The root page is a television. The checkbox is the power switch, so no JavaScript.
 * Switching off squashes the picture to a bright line, then a dot, then black; switching on runs it backwards.
 * Each state's rule holds the transitions for arriving in that state.
 */
.tv {
  background: #000;
}

.tube {
  position: fixed;
  inset: 0;
  transition:
    opacity 0.05s,
    transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1) 0.2s,
    visibility 0s;
}

.picture {
  position: absolute;
  inset: 0;
  background-color: var(--bg);
  transition:
    transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1) 0.05s,
    background-color 0.4s ease 0.45s;
}

.tube .solo {
  transition: opacity 0.3s ease 0.45s;
}

.power:not(:checked) ~ .tube {
  transform: scaleY(0.004);
  opacity: 0;
  visibility: hidden;
  transition:
    transform 0.22s cubic-bezier(0.6, 0, 0.9, 0.4),
    opacity 0.3s ease 0.5s,
    visibility 0s 0.8s;
}

.power:not(:checked) ~ .tube .picture {
  transform: scaleX(0.006);
  background-color: #fff;
  transition:
    transform 0.2s cubic-bezier(0.6, 0, 0.9, 0.4) 0.2s,
    background-color 0.12s;
}

.power:not(:checked) ~ .tube .solo {
  opacity: 0;
  transition: opacity 0.1s;
}

.power-button {
  position: fixed;
  z-index: 1;
  left: 50%;
  bottom: max(1.5rem, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--muted);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  opacity: 0;
  animation: arrive 0.9s ease-out 1.6s forwards;
  transition: color 0.3s;
}

.power-button::before {
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M12 3v8M6.3 6.3a8 8 0 1 0 11.4 0'/%3E%3C/svg%3E");
  content: "";
  width: 22px;
  height: 22px;
  background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}

.power-button:hover {
  color: var(--text);
}

.power:focus-visible ~ .power-button {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

.power:not(:checked) ~ .power-button {
  color: #555;
}

.power:not(:checked) ~ .power-button:hover {
  color: #999;
}

@media (prefers-reduced-motion: reduce) {
  .solo .later,
  .power-button {
    opacity: 1;
    animation: none;
  }

  .tube,
  .tube .picture,
  .tube .solo,
  .power:not(:checked) ~ .tube,
  .power:not(:checked) ~ .tube .picture,
  .power:not(:checked) ~ .tube .solo {
    transition: none;
  }
}
