/*
 * Two colors only: Canvas and CanvasText. Everything else is opacity,
 * so the whole page flips with the system light/dark scheme for free.
 */
:root {
  color-scheme: light dark;
  --ink-dim: color-mix(in srgb, CanvasText 30%, transparent);
  --ink-half: color-mix(in srgb, CanvasText 55%, transparent);
}

* { box-sizing: border-box; }

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

body {
  background: Canvas;
  color: CanvasText;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  overflow: hidden;
  transition: background-color 0.5s ease, color 0.5s ease;
}

#vortex {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

main {
  position: fixed;
  inset: 0;
}

#cipher-form {
  position: absolute;
  top: 75%;
  left: 50%;
  transform: translate(-50%, -50%);
  transition: opacity 0.6s ease;
}

body.solved #cipher-form {
  opacity: 0;
  pointer-events: none;
}

/* One input masked as eight cells: a monospace glyph occupies 1ch, so
   letter-spacing pads each character out to a fixed cell width, and the
   background gradient draws one underline dash per cell. */
#cipher-input {
  --cell-w: clamp(2.25rem, 10.5vw, 3rem);
  --line: var(--ink-dim);
  box-sizing: content-box;
  width: calc(var(--cell-w) * 8 + 2px);
  padding: 0 0 0.65rem calc((var(--cell-w) - 1ch) / 2);
  border: 0;
  outline: 0;
  background-color: transparent;
  font-family: inherit;
  font-size: 1.6rem;
  letter-spacing: calc(var(--cell-w) - 1ch);
  text-transform: uppercase;
  color: CanvasText;
  caret-color: var(--ink-half);
  background-image: repeating-linear-gradient(to right,
    var(--line) 0,
    var(--line) calc(var(--cell-w) - 12px),
    transparent calc(var(--cell-w) - 12px),
    transparent var(--cell-w));
  background-size: calc(var(--cell-w) * 8) 2px;
  background-repeat: no-repeat;
  background-position: 6px bottom;
}

#cipher-input:focus {
  --line: var(--ink-half);
}

#cipher-input::selection {
  background: var(--ink-dim);
}

#reveal {
  position: absolute;
  top: 75%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  text-align: center;
  opacity: 0;
  transition: opacity 1.4s ease;
}

#reveal.shown {
  opacity: 1;
}

#reveal a {
  color: CanvasText;
  font-size: clamp(1rem, 4vw, 1.35rem);
  letter-spacing: 0.14em;
  text-decoration: none;
  border-bottom: 1px solid var(--ink-dim);
  padding-bottom: 0.35rem;
}

#reveal a:hover {
  border-bottom-color: var(--ink-half);
}

#reset {
  display: block;
  margin: 1.6rem auto 0;
  padding: 0.3rem 0.9rem;
  background: none;
  border: 1px solid var(--ink-dim);
  border-radius: 999px;
  color: var(--ink-half);
  font-family: inherit;
  font-size: 0.75rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  cursor: pointer;
}

#reset:hover {
  color: CanvasText;
  border-color: var(--ink-half);
}

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

@media (prefers-reduced-motion: reduce) {
  #cipher-form,
  #reveal,
  body {
    transition: none;
  }
}
