# Webcore captcha

Joke captcha dialog: a big tick box, a binary code field and yes or no keys in retro OS chrome\.

- Kind: element
- Category: frames
- Default background: light
- Use when: Guestbook speed bumps, playful sign\-up gags and Y2K landing pages\.
- Avoid when: Real bot protection: it checks nothing, so pair it with a real check if you need one\.
- Requires: It verifies nothing on its own; wire the tick box and buttons to your own logic\.
- Kit: [Webcore](https://thuvien.org/ui/kits/webcore.md)
- Credit: [Luna UI](https://thuvien.org/ui)
- License: MIT

## Variants

Add one variant class next to the root element's class.

- [Pink](https://thuvien.org/ui/elements/webcore-captcha?variant=pink): default, no extra class
- [Lilac](https://thuvien.org/ui/elements/webcore-captcha?variant=lilac): `tv-webcore-captcha--lilac`

## HTML

```html
<section class="tv-webcore-captcha">
  <header class="tv-webcore-captcha-bar">
    <h3 class="tv-webcore-captcha-title">(1) captcha</h3>
    <span class="tv-webcore-captcha-close" aria-hidden="true"></span>
  </header>
  <div class="tv-webcore-captcha-body">
    <label class="tv-webcore-captcha-check">
      <input class="tv-webcore-captcha-box" type="checkbox" checked>
      <span>I'm not a robot</span>
    </label>
    <div class="tv-webcore-captcha-actions">
      <input class="tv-webcore-captcha-code" type="text" value="00110001" aria-label="Type the code" size="8">
      <button class="tv-webcore-captcha-button" type="button">yes</button>
      <button class="tv-webcore-captcha-button" type="button">no</button>
    </div>
  </div>
</section>
```

## CSS

```css
/* A joke captcha in retro OS chrome: a big pixel tick, a code field and two keys. */
.tv-webcore-captcha {
  --tv-webcore-captcha-bar: var(--tv-webcore-pink, #f7b5e4);
  box-sizing: border-box;
  width: 100%;
  max-width: 28rem;
  margin: 0 auto;
  border: 2px solid var(--tv-webcore-lilac, #a49bf3);
  background: var(--tv-webcore-grey, #d9d9e5);
  color: var(--tv-webcore-navy, #2c2b9f);
  font: 14px/1.4 "Lucida Console", "Courier New", ui-monospace, monospace;
  box-shadow: 4px 4px 0 color-mix(in srgb, var(--tv-webcore-navy, #2c2b9f) 25%, transparent);
}

.tv-webcore-captcha-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 30px;
  padding: 3px 4px 3px 10px;
  background: var(--tv-webcore-captcha-bar, #f7b5e4);
}

.tv-webcore-captcha-title {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.tv-webcore-captcha-close {
  position: relative;
  flex-shrink: 0;
  box-sizing: border-box;
  width: 22px;
  height: 20px;
  border: 1px solid var(--tv-webcore-navy, #2c2b9f);
  background: var(--tv-webcore-paper, #ffffff);
}

.tv-webcore-captcha-close::before,
.tv-webcore-captcha-close::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 12px;
  height: 2px;
  background: var(--tv-webcore-navy, #2c2b9f);
  transform: translate(-50%, -50%) rotate(45deg);
}

.tv-webcore-captcha-close::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.tv-webcore-captcha-body {
  display: grid;
  gap: 22px;
  padding: 26px 18px 18px;
}

.tv-webcore-captcha-check {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
}

/* A dotted box that fills with a big pixel tick. */
.tv-webcore-captcha-box {
  flex-shrink: 0;
  box-sizing: border-box;
  width: 40px;
  height: 34px;
  margin: 0;
  border: 2px dotted var(--tv-webcore-navy, #2c2b9f);
  background: transparent no-repeat center / 36px 30px;
  appearance: none;
  cursor: pointer;
}

.tv-webcore-captcha-box:checked {
  border-color: transparent;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 10' shape-rendering='crispEdges'%3E%3Cpath d='M0 5h2v1h1v1h1v1h1V7h1V6h1V5h1V4h1V3h1V2h1V1h1v2h-1v1h-1v1H9v1H8v1H7v1H6v1H5v1H4V9H3V8H2V7H1V6H0z' fill='%232c2b9f'/%3E%3C/svg%3E");
}

/* The code field, then yes and no; the field gets a little more room for its eight digits. */
.tv-webcore-captcha-actions {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.tv-webcore-captcha-code,
.tv-webcore-captcha-button {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  min-height: 2.5rem;
  padding: 4px 6px;
  border: 1px solid var(--tv-webcore-navy, #2c2b9f);
  border-radius: 0;
  background: var(--tv-webcore-pink, #f7b5e4);
  color: var(--tv-webcore-navy, #2c2b9f);
  font: inherit;
  letter-spacing: 0.1em;
  text-align: center;
  text-transform: uppercase;
}

.tv-webcore-captcha-code {
  letter-spacing: 0.04em;
  box-shadow: inset 0 0 0 3px var(--tv-webcore-pink, #f7b5e4), inset 0 0 0 4px var(--tv-webcore-navy, #2c2b9f);
}

.tv-webcore-captcha-button {
  cursor: pointer;
}

.tv-webcore-captcha-button:hover {
  background: color-mix(in srgb, var(--tv-webcore-pink, #f7b5e4) 60%, var(--tv-webcore-paper, #ffffff));
}

.tv-webcore-captcha-button:active {
  transform: translate(1px, 1px);
}

.tv-webcore-captcha-box:focus-visible,
.tv-webcore-captcha-code:focus-visible,
.tv-webcore-captcha-button:focus-visible {
  outline: 2px dashed var(--tv-webcore-navy, #2c2b9f);
  outline-offset: 3px;
}

.tv-webcore-captcha--lilac {
  --tv-webcore-captcha-bar: var(--tv-webcore-lilac, #a49bf3);
}
```
