/* The form that goes in the kiln: a slab of buff stoneware on a black page, with wells pressed into it for the
   text, little clay tiles for the choices and a cobalt button; the raw glaze, the iron red of a mistake and the
   three fired glazes of the tile that comes out of the kiln. */
:root {
  --page: #000000;          /* the page */
  --clay: #e4d8c5;          /* the slab, buff stoneware */
  --well: #d4c5ad;          /* a well pressed into the slab */
  --chip: #ece2d2;          /* a choice, a little tile standing on the slab */
  --ink: #2a1f17;           /* the words */
  --soft: #5b493a;          /* the quieter words */
  --cobalt: #2a4bb0;        /* the potter's blue: focus, a choice, a tick, the button */
  --iron: #a2321f;          /* iron red: something to fix */
  --raw: #f5f0e7;           /* the raw glaze brushed on a field that is right */
  --celadon: #b2cfc0;       /* the fired glazes: celadon */
  --celadon-deep: #8fb3a3;
  --celadon-ink: #163a2e;
  --tenmoku: #3a2318;       /* tenmoku */
  --tenmoku-deep: #1d110b;
  --tenmoku-ink: #f2e2cf;
  --tenmoku-rim: #9a5426;
  --shino: #efd8bd;         /* shino */
  --shino-deep: #e2b78f;
  --shino-ink: #4a2815;
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Bricolage Grotesque Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.stage {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 48px 16px;
}

.kiln {
  width: min(400px, 100%);
  margin: 0;
}

/* ---------------------------------------------------------------- the slab */
.slab {
  --halo: 0 0 0 0 rgba(0, 0, 0, 0), 0 0 0 0 rgba(0, 0, 0, 0);
  --glow: #000000;
  --glow-in: #000000;
  position: relative;
  margin: 0 auto;
  border-radius: 28px;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(120% 80% at 18% 0%, rgba(255, 255, 255, 0.32), rgba(255, 255, 255, 0) 55%),
    linear-gradient(180deg, var(--clay), color-mix(in srgb, var(--clay) 92%, #8a6b4a));
  background-color: var(--clay);
  box-shadow: var(--halo), inset 0 1px 0 rgba(255, 255, 255, 0.55), inset 0 -2px 0 rgba(90, 64, 40, 0.14);
}

/* the kiln's light: the ambient that goes dark, the glow of the clay itself, and at the top a veil of the same
   light, under which the form becomes the tile */
.slab__dark,
.slab__glow,
.slab__veil {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
}

.slab__dark {
  z-index: 5;
  background: #000000;
  opacity: 0;
}

.slab__glow {
  background: radial-gradient(120% 100% at 50% 50%, var(--glow-in) 25%, var(--glow) 100%);
}

.slab__veil {
  background: radial-gradient(120% 100% at 50% 50%, var(--veil-in, #000000) 25%, var(--veil, #000000) 100%);
}

.slab__glow {
  z-index: 6;
  mix-blend-mode: screen;
  visibility: hidden;
}

.slab__veil {
  z-index: 7;
  opacity: 0;
}

/* the kiln at its hottest is never an even light: brighter patches that drift and breathe, added on top */
.slab__flame {
  position: absolute;
  z-index: 8;
  inset: -20%;
  background:
    radial-gradient(26% 20% at 30% 34%, rgba(255, 252, 240, 0.7), rgba(255, 252, 240, 0) 70%),
    radial-gradient(22% 28% at 72% 60%, rgba(255, 244, 214, 0.6), rgba(255, 244, 214, 0) 70%),
    radial-gradient(30% 18% at 52% 84%, rgba(255, 248, 228, 0.55), rgba(255, 248, 228, 0) 70%),
    radial-gradient(18% 24% at 16% 72%, rgba(255, 238, 200, 0.5), rgba(255, 238, 200, 0) 70%),
    radial-gradient(20% 16% at 80% 18%, rgba(255, 246, 220, 0.5), rgba(255, 246, 220, 0) 70%);
  mix-blend-mode: screen;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* ---------------------------------------------------------------- the form */
.face {
  padding: 28px 24px 24px;
}

.head__title {
  margin: 0;
  font-family: 'Fraunces Variable', Georgia, serif;
  font-size: 28px;
  font-weight: 600;
  font-variation-settings: 'SOFT' 100;
  line-height: 32px;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.head__sub {
  margin: 8px 0 0;
  text-wrap: pretty;
  font-size: 14px;
  line-height: 20px;
  color: var(--soft);
}

.field {
  margin: 20px 0 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.field + .field {
  margin-top: 16px;
}

.field__label {
  display: block;
  margin: 0 0 8px 4px;
  padding: 0;
  font-size: 14px;
  font-weight: 620;
  line-height: 18px;
  color: var(--ink);
}

/* ---------------------------------------------------------------- a well for words */
.well {
  position: relative;
  height: 48px;
  border-radius: 14px;
  background: var(--well);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
  transition: box-shadow 0.16s ease, background-color 0.2s ease;
}

/* the depth of the well, over the glaze too */
.well::after {
  content: '';
  position: absolute;
  z-index: 1;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 2px 3px rgba(74, 50, 28, 0.2), inset 0 0 0 1px rgba(74, 50, 28, 0.1);
  pointer-events: none;
}

@media (hover: hover) and (pointer: fine) {
  .well:hover {
    background: color-mix(in srgb, var(--well) 92%, #6b4c30);
  }
}

.well.is-on {
  background: #e3d8c7;
  background: color-mix(in srgb, var(--well) 70%, #ffffff);
  box-shadow: 0 0 0 2px var(--cobalt), 0 0 0 6px rgba(42, 75, 176, 0.18);
  box-shadow: 0 0 0 2px var(--cobalt), 0 0 0 6px color-mix(in srgb, var(--cobalt) 18%, transparent);
}

.well.is-wrong {
  background: #ddc9b9;
  background: color-mix(in srgb, color-mix(in srgb, var(--well) 64%, #ffffff) 90%, var(--iron));
  box-shadow: 0 0 0 2px var(--iron), 0 0 0 6px rgba(162, 50, 31, 0.16);
  box-shadow: 0 0 0 2px var(--iron), 0 0 0 6px color-mix(in srgb, var(--iron) 16%, transparent);
}

.well__input {
  position: relative;
  z-index: 2;
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0 44px 0 16px;
  border: 0;
  border-radius: inherit;
  outline: none;
  background: transparent;
  color: var(--ink);
  caret-color: var(--cobalt);
  font: 520 16px/normal 'Bricolage Grotesque Variable', system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.well__input::placeholder {
  color: var(--soft);
  opacity: 1;
}

/* the browser's autofill paints the field blue: back to the clay */
.well__input:-webkit-autofill {
  -webkit-text-fill-color: var(--ink);
  -webkit-box-shadow: 0 0 0 48px var(--well) inset;
  caret-color: var(--cobalt);
}

/* the caret of the library's preview, which types without taking the focus */
.well__caret {
  position: absolute;
  z-index: 3;
  left: 0;
  top: 50%;
  width: 2px;
  height: 20px;
  margin-top: -10px;
  border-radius: 1px;
  background: var(--cobalt);
  opacity: 0;
  pointer-events: none;
}

.well__caret.is-on {
  animation: blink 1.06s steps(1) infinite;
}

@keyframes blink {
  0%,
  50% {
    opacity: 1;
  }

  50.01%,
  100% {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .well__caret.is-on {
    animation: none;
    opacity: 1;
  }
}

/* the raw glaze: strips of a brush, drawn by the script */
.coat {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: inherit;
  pointer-events: none;
}

.coat rect {
  fill: var(--raw);
}

.tick {
  position: absolute;
  z-index: 3;
  right: 12px;
  top: 50%;
  width: 20px;
  height: 20px;
  margin-top: -10px;
  overflow: visible;
  pointer-events: none;
}

.tick path {
  fill: none;
  stroke: var(--cobalt);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
}

/* ---------------------------------------------------------------- the line under a field */
.field__msg {
  height: 0;
  overflow: hidden;
}

.msg {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0;
  padding: 8px 4px 0;
  font-size: 14px;
  font-weight: 520;
  line-height: 18px;
  color: var(--iron);
}

.msg svg {
  flex: none;
  width: 16px;
  height: 16px;
  margin-top: 1px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------------------------------------------------------------- the choices: little tiles on the slab */
.picks {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.pick {
  position: relative;
  display: block;
  min-width: 0;
}

/* the real radio lies over its tile, invisible: the keyboard, a tap and screen readers use it */
.pick input {
  position: absolute;
  z-index: 3;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.pick input:disabled {
  cursor: not-allowed;
}

.pick__body {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  height: 56px;
  padding: 0 8px;
  border-radius: 14px;
  background: var(--chip);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 2px 0 rgba(90, 64, 40, 0.2), 0 3px 8px rgba(90, 64, 40, 0.12);
  color: var(--ink);
  text-align: center;
  transition: transform 0.22s cubic-bezier(0.3, 1.6, 0.5, 1), box-shadow 0.22s ease, color 0.2s ease;
}

.field[data-field='glaze'] .pick__body {
  height: 64px;
  gap: 4px;
}

.pick__main,
.pick__sub {
  position: relative;
  z-index: 1;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pick__main {
  font-size: 15px;
  font-weight: 640;
  line-height: 18px;
}

.pick__sub {
  font-size: 13px;
  font-weight: 480;
  line-height: 16px;
  color: var(--soft);
}

.bowl {
  position: relative;
  z-index: 1;
  width: 40px;
  height: 20px;
  overflow: visible;
}

.bowl__glaze {
  stroke: rgba(42, 31, 23, 0.28);
  stroke-width: 1;
}

.bowl--celadon {
  fill: var(--celadon-deep);
}

.bowl--tenmoku {
  fill: var(--tenmoku);
}

.bowl--shino {
  fill: var(--shino-deep);
}

.bowl__shine {
  fill: none;
  stroke: rgba(255, 255, 255, 0.7);
  stroke-width: 1.6;
  stroke-linecap: round;
}

.tick--pick {
  right: 6px;
  top: 6px;
  width: 14px;
  height: 14px;
  margin-top: 0;
}

.tick--pick path {
  stroke-width: 2.6;
}

@media (hover: hover) and (pointer: fine) {
  .pick:hover input:not(:disabled):not(:checked) + .pick__body {
    transform: translateY(-2px);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 4px 0 rgba(90, 64, 40, 0.18), 0 8px 14px rgba(90, 64, 40, 0.16);
  }
}

.pick input:not(:disabled):active + .pick__body {
  transform: translateY(1px);
  transition-duration: 0.08s;
}

/* the edge of a tile, over its glaze: blue when chosen, iron red when a choice is missing */
.pick__body::after {
  content: '';
  position: absolute;
  z-index: 2;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1.5px var(--cobalt), inset 0 2px 3px rgba(74, 50, 28, 0.16);
  opacity: 0;
  transition: opacity 0.18s ease;
  pointer-events: none;
}

/* chosen: pressed into the slab, blue at the edge, and glazed */
.pick input:checked + .pick__body {
  transform: translateY(1px);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
  color: var(--cobalt);
}

.pick input:checked + .pick__body::after {
  opacity: 1;
}

.pick input:checked + .pick__body .pick__sub {
  color: color-mix(in srgb, var(--cobalt) 80%, var(--ink));
}

.pick input:focus-visible + .pick__body {
  outline: 2px solid var(--cobalt);
  outline-offset: 2px;
}

/* full: flat on the slab, not a tile any more */
.pick input:disabled + .pick__body {
  background: transparent;
  box-shadow: inset 0 0 0 1px rgba(74, 50, 28, 0.22);
  color: color-mix(in srgb, var(--soft) 82%, var(--clay));
}

.pick input:disabled + .pick__body .pick__main {
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
}

.pick input:disabled + .pick__body .pick__sub {
  color: inherit;
}

.field.is-wrong .pick input:not(:disabled) + .pick__body::after {
  box-shadow: inset 0 0 0 1.5px var(--iron);
  opacity: 1;
}

/* ---------------------------------------------------------------- the button */
.fire {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 52px;
  margin: 24px 0 0;
  padding: 0 24px;
  border: 0;
  border-radius: 16px;
  background: transparent;
  color: #ffffff;
  font: 640 16px/1 'Bricolage Grotesque Variable', system-ui, sans-serif;
  cursor: pointer;
  isolation: isolate;
  -webkit-tap-highlight-color: transparent;
}

.fire > :not(.fire__bg) {
  grid-area: 1 / 1;
}

/* the colour is a layer of its own: it swells under the pointer while the words widen */
.fire__bg {
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background:
    radial-gradient(120% 140% at 30% 0%, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0) 50%),
    linear-gradient(180deg, color-mix(in srgb, var(--cobalt) 86%, #ffffff), var(--cobalt));
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.22), 0 2px 0 rgba(20, 30, 80, 0.3), 0 6px 14px rgba(20, 30, 80, 0.24);
  transition: inset 0.6s cubic-bezier(0.3, 1.7, 0.45, 1), transform 0.16s ease-out;
}

.fire__label,
.fire__heat {
  display: block;
  font-stretch: 88%;
  white-space: nowrap;
  transition: font-stretch 0.6s cubic-bezier(0.3, 1.7, 0.45, 1);
}

.fire__heat {
  opacity: 0;
  font-variant-numeric: tabular-nums;
}

@media (hover: hover) and (pointer: fine) {
  .fire:not([aria-disabled='true']):hover .fire__bg {
    inset: -2px -3px;
  }

  .fire:not([aria-disabled='true']):hover .fire__label {
    font-stretch: 100%;
  }
}

.fire:not([aria-disabled='true']):active .fire__bg {
  transform: scale(0.97);
}

.fire[aria-disabled='true'] {
  cursor: default;
}

.fire:focus-visible {
  outline: 2px solid var(--cobalt);
  outline-offset: 3px;
}

/* ---------------------------------------------------------------- the tile out of the kiln */
.tile {
  --t-bg: var(--celadon);
  --t-deep: var(--celadon-deep);
  --t-ink: var(--celadon-ink);
  --t-rim: color-mix(in srgb, var(--celadon) 60%, #ffffff);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 28px;
  min-height: 100%;
  padding: 32px 28px 28px;
  overflow: hidden;
  border-radius: inherit;
  background:
    radial-gradient(90% 60% at 20% 4%, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0) 60%),
    radial-gradient(140% 90% at 50% 120%, color-mix(in srgb, var(--t-deep) 85%, #000000), rgba(0, 0, 0, 0) 60%),
    linear-gradient(172deg, var(--t-bg), var(--t-deep));
  background-color: var(--t-bg);
  box-shadow: inset 0 0 0 2px var(--t-rim), inset 0 3px 4px rgba(255, 255, 255, 0.35), inset 0 -26px 40px -24px rgba(0, 0, 0, 0.3);
  color: var(--t-ink);
}

.tile[hidden] {
  display: none;
}

.tile[data-glaze='tenmoku'] {
  --t-bg: var(--tenmoku);
  --t-deep: var(--tenmoku-deep);
  --t-ink: var(--tenmoku-ink);
  --t-rim: var(--tenmoku-rim);
}

.tile[data-glaze='shino'] {
  --t-bg: var(--shino);
  --t-deep: var(--shino-deep);
  --t-ink: var(--shino-ink);
  --t-rim: color-mix(in srgb, var(--shino-deep) 70%, #c96a35);
}

/* the gloss: a highlight that runs across once when the tile is out */
.tile__shine {
  position: absolute;
  top: 0;
  bottom: 0;
  left: -70%;
  width: 60%;
  background: linear-gradient(105deg, rgba(255, 255, 255, 0) 20%, rgba(255, 255, 255, 0.4) 50%, rgba(255, 255, 255, 0) 80%);
  pointer-events: none;
}

/* words pressed into the clay: the glaze pools in them, darker, and the lower edge catches the light */
.tile__kicker,
.tile__title,
.tile__facts {
  position: relative;
  text-shadow: 0 1px 0 color-mix(in srgb, var(--t-bg) 40%, #ffffff);
}

.tile[data-glaze='tenmoku'] .tile__kicker,
.tile[data-glaze='tenmoku'] .tile__title,
.tile[data-glaze='tenmoku'] .tile__facts {
  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.6);
}

.tile__kicker {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 16px;
  font-weight: 640;
  line-height: 20px;
}

.tile__kicker svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tile__title {
  margin: 12px 0 0;
  font-family: 'Fraunces Variable', Georgia, serif;
  font-size: 34px;
  font-weight: 600;
  font-variation-settings: 'SOFT' 100;
  line-height: 40px;
  letter-spacing: -0.01em;
  outline: none;
}

.tile__facts {
  display: grid;
  margin: 0;
}

.tile__facts div {
  display: grid;
  gap: 4px;
  padding: 12px 0;
  border-top: 1px solid color-mix(in srgb, var(--t-ink) 18%, transparent);
}

.tile__facts div:last-child {
  border-bottom: 1px solid color-mix(in srgb, var(--t-ink) 18%, transparent);
}

.tile__facts dt {
  font-size: 15px;
  font-weight: 520;
  line-height: 20px;
  opacity: 0.86;
}

.tile__facts dd {
  margin: 0;
  font-size: 18px;
  font-weight: 620;
  line-height: 24px;
  overflow-wrap: anywhere;
}

.tile__note {
  position: relative;
  text-wrap: pretty;
  margin: -4px 0 0;
  font-size: 16px;
  line-height: 24px;
  color: var(--t-ink);
}

.again {
  position: relative;
  display: grid;
  place-items: center;
  height: 56px;
  margin: auto 0 0;
  padding: 0 24px;
  border: 0;
  border-radius: 16px;
  background: transparent;
  color: var(--t-ink);
  font: 620 17px/1 'Bricolage Grotesque Variable', system-ui, sans-serif;
  cursor: pointer;
  isolation: isolate;
  -webkit-tap-highlight-color: transparent;
}

.again > :not(.again__bg) {
  grid-area: 1 / 1;
}

.again__bg {
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: color-mix(in srgb, var(--t-bg) 70%, #ffffff);
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--t-ink) 30%, transparent), 0 1px 0 rgba(255, 255, 255, 0.4);
  transition: inset 0.6s cubic-bezier(0.3, 1.7, 0.45, 1), transform 0.16s ease-out;
}

.tile[data-glaze='tenmoku'] .again__bg {
  background: color-mix(in srgb, var(--t-bg) 80%, #ffffff);
}

.again__label {
  font-stretch: 88%;
  white-space: nowrap;
  transition: font-stretch 0.6s cubic-bezier(0.3, 1.7, 0.45, 1);
}

@media (hover: hover) and (pointer: fine) {
  .again:hover .again__bg {
    inset: -2px -3px;
  }

  .again:hover .again__label {
    font-stretch: 100%;
  }
}

.again:active .again__bg {
  transform: scale(0.97);
}

.again:focus-visible {
  outline: 2px solid var(--t-ink);
  outline-offset: 3px;
}

/* for screen readers only */
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 420px) {
  .face {
    padding: 24px 20px 20px;
  }

  .tile {
    gap: 24px;
    padding: 28px 24px 24px;
  }

  .tile__title {
    font-size: 32px;
    line-height: 36px;
  }

  .head__title {
    font-size: 26px;
    line-height: 30px;
  }
}
