:root {
  --gap: 2rem;
  --min-width: min(calc(100vw - 3rem), calc(32ch + var(--gap)));
  --muted: #757575;
  --padding: 1ch;
  --primary: #000;
  --secondary: #fff;
}

@media (prefers-color-scheme: dark) {
  :root {
    --primary: #fff;
    --secondary: #000;
  }
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--secondary);
  color: var(--primary);
  display: flex;
  flex-direction: column;
  font-family: "Atkinson Hyperlegible", sans-serif;
  font-size: calc(14pt + 0.5vw);
  -webkit-user-select: none;
  user-select: none;
}

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

article,
form {
  margin: auto;
  min-width: var(--min-width);
  padding: var(--padding);
  width: 50%;
}

main {
  align-items: center;
  display: flex;
  flex-grow: 1;
  justify-content: center;
  overflow: auto;
}

/* Last visible child */
main > *:nth-last-child(1 of :not([hidden])) {
  padding-bottom: calc(var(--gap) + 3ch + 0.667em);
}

.target-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr));
  gap: var(--gap);
}

.target {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.target > p {
  margin-top: auto;
}

.target > iframe {
  aspect-ratio: 8.5 / 11;
  border: 0;
  width: 100%;
}

form {
  align-items: center;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.button {
  background-color: var(--primary);
  border: 1px var(--primary) solid;
  color: var(--secondary);
  cursor: pointer;
  font-weight: bold;
  height: 0.667em;
  line-height: 0.667em;
  padding: var(--padding);
  text-decoration-line: none;
}

@supports (text-box: trim-both cap alphabetic) {
  .button {
    height: unset;
    line-height: unset;
    text-box: trim-both cap alphabetic;
  }
}

.button-disabled,
.button:disabled {
  background-color: var(--secondary);
  color: var(--muted);
  cursor: default;
}

input,
textarea {
  all: unset;
  border-bottom: 1px var(--primary) solid;
}

input:not(.button):read-only,
textarea:read-only {
  pointer-events: none;
}

textarea {
  border-right: 1px var(--primary) solid;
  overflow-wrap: break-word;
}

textarea:read-only {
  color: transparent;
  overflow: hidden;
  overflow-wrap: unset;
}

.input-container {
  display: grid;
  width: 100%;
}

.input-container * {
  grid-column: 1;
  grid-row: 1;
  width: 100%;
}

.horizontal-container {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap);
  justify-content: space-between;
  width: 100%;
}

.horizontal-container .input-container {
  flex: 16ch;
}

input + label,
textarea + label {
  color: var(--muted);
  pointer-events: none;
  transform-origin: bottom left;
  transition:
    color 0.25s,
    transform 0.25s,
    width 0.25s;
}

input:focus + label,
input:not(:placeholder-shown) + label,
textarea:focus + label,
textarea:not(:read-only, :placeholder-shown) + label {
  color: var(--primary);
  cursor: default;
  transform: scale(75%) translate(0, 100%);
  width: calc(100% + (100% / 3));
}

nav {
  background: var(--secondary);
  bottom: var(--padding);
  box-shadow: 0 0 0.5ch 1ch var(--secondary);
  display: flex;
  gap: var(--padding);
  justify-content: center;
  left: 50%;
  position: fixed;
  transform: translate(-50%);
}

[hidden],
.cf-turnstile {
  display: none;
}
